diff options
author | Jim Meyering <jim@meyering.net> | 2001-03-17 08:50:51 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2001-03-17 08:50:51 +0000 |
commit | 9f9610d9833dd394269443111e4e612c55cdd820 (patch) | |
tree | 5eb35a461c6d977e6d55177dd544bef62881acd4 /src | |
parent | 1499642b50b905758957628a4d87ee797f694e3a (diff) | |
download | coreutils-9f9610d9833dd394269443111e4e612c55cdd820.tar.xz |
(INT_STRLEN_BOUND): New macro.
Diffstat (limited to 'src')
-rw-r--r-- | src/sys2.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/sys2.h b/src/sys2.h index 2ed46b16b..48af648c3 100644 --- a/src/sys2.h +++ b/src/sys2.h @@ -488,6 +488,11 @@ enum ? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) : (t) 0)) #define TYPE_MAXIMUM(t) ((t) (~ (t) 0 - TYPE_MINIMUM (t))) +/* Upper bound on the string length of an integer converted to string. + 302 / 1000 is ceil (log10 (2.0)). Subtract 1 for the sign bit; + add 1 for integer division truncation; add 1 more for a minus sign. */ +#define INT_STRLEN_BOUND(t) ((sizeof (t) * CHAR_BIT - 1) * 302 / 1000 + 2) + #ifndef CHAR_MIN # define CHAR_MIN TYPE_MINIMUM (char) #endif |