bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug-gnulib] Re: [bug-grep] Re: length of dec. representation of a numbe


From: Paul Jarc
Subject: [bug-gnulib] Re: [bug-grep] Re: length of dec. representation of a number
Date: Thu, 10 Mar 2005 14:34:31 -0500
User-agent: Gnus/5.110003 (No Gnus v0.3) Emacs/21.4 (gnu/linux)

Stepan Kasal <address@hidden> wrote:
>> #define TYPE_MAXIMUM(t) \
>>   ((t) (! TYPE_SIGNED (t) \
>>      ? (t) -1 \
>>      : ~ (~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))))
>
> For unsigned types on signed magnitude hosts, ((t) -1) is wrong.

No, the standard explicitly says it's correct, for any representation.
Conversion of an out-of-range value to an unsigned type works by
reducing the value module <type>_MAX+1, so (type)-1==<type>_MAX.


paul




reply via email to

[Prev in Thread] Current Thread [Next in Thread]