[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-grep] length of dec. representation of a number
From: |
Jim Meyering |
Subject: |
Re: [bug-grep] length of dec. representation of a number |
Date: |
Tue, 08 Mar 2005 18:59:16 +0100 |
address@hidden (Paul Jarc) wrote:
> Jim Meyering <address@hidden> wrote:
>> Another such header file might include definitions for TYPE_MINIMUM and
>> TYPE_MAXIMUM
>
> For unsigned types, they're trivial, and for signed types, I don't
> it's possible to calculate them unless you either invoke
> unspecified/undefined behavior, or make assumptions about padding bits
> and 2's-complement/1's-complement/sign+magnitude representation.
Here are the ones that have been in coreutils/src/system.h, gnulib,
and other packages for a long time. If you know of a system that's
actually in use but for which they don't work, please let us know.
/* The extra casts work around common compiler bugs. */
#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
/* The outer cast is needed to work around a bug in Cray C 5.0.3.0.
It is necessary at least when t == time_t. */
#define TYPE_MINIMUM(t) ((t) (TYPE_SIGNED (t) \
? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) : (t) 0))
#define TYPE_MAXIMUM(t) ((t) (~ (t) 0 - TYPE_MINIMUM (t)))
- Re: [bug-grep] length of dec. representation of a number, Paul Jarc, 2005/03/04
- Re: [bug-grep] length of dec. representation of a number, Paul Eggert, 2005/03/05
- [bug-grep] Re: length of dec. representation of a number, Stepan Kasal, 2005/03/07
- Re: [bug-grep] length of dec. representation of a number, Jim Meyering, 2005/03/08
- Re: [bug-grep] length of dec. representation of a number, Paul Jarc, 2005/03/08
- Re: [bug-grep] length of dec. representation of a number,
Jim Meyering <=
- Re: [bug-gnulib] Re: [bug-grep] length of dec. representation of a number, Stepan Kasal, 2005/03/09
- Re: [bug-gnulib] Re: [bug-grep] length of dec. representation of a number, Paul Jarc, 2005/03/09
- [bug-grep] Re: length of dec. representation of a number, Paul Eggert, 2005/03/09
- [bug-grep] Re: length of dec. representation of a number, Paul Jarc, 2005/03/10
- Re: [bug-grep] Re: length of dec. representation of a number, Jim Meyering, 2005/03/10
- Re: length of dec. representation of a number [bug-grep] [bug-gnulib], Stepan Kasal, 2005/03/10
- Re: [bug-grep] Re: length of dec. representation of a number, Paul Jarc, 2005/03/10
- Re: [bug-grep] Re: length of dec. representation of a number, Jim Meyering, 2005/03/10
- Re: [bug-grep] Re: length of dec. representation of a number, Stepan Kasal, 2005/03/10
- Re: [bug-grep] Re: length of dec. representation of a number, Paul Jarc, 2005/03/10