[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-grep] Re: length of dec. representation of a number
From: |
Jim Meyering |
Subject: |
Re: [bug-grep] Re: length of dec. representation of a number |
Date: |
Thu, 10 Mar 2005 09:53:22 +0100 |
address@hidden (Paul Jarc) wrote:
> Paul Eggert <address@hidden> wrote:
>> /* Bound on length of the string representing an integer value or type T.
>> Subtract 1 for the sign bit if t is signed; log10 (2.0) < 146/485;
>> add 1 for integer division truncation; add 1 more for a minus sign
>> if needed. */
>> #define INT_STRLEN_BOUND(t) \
>> ((sizeof (t) * CHAR_BIT - 1) * 146 / 485 + 2)
>
> I guess that should be:
> #define INT_STRLEN_BOUND(t) \
> ((sizeof (t) * CHAR_BIT - TYPE_SIGNED(t)) * 146 / 485 + TYPE_SIGNED(t) + 1)
Technically, yes, but that would prohibit applying that macro
to variables, which is useful. Currently there are uses like
that in the coreutils.