Paul Eggert wrote:
> >      : ((((zero) + 1) << ((bits) ? (bits) - 1 : 0)) - 1) * 2 + 1)
> 
> Hmm, that's not quite right either, surely you meant (bits) - 2.

No, it appears correct as it is. For example, if bits==32, it will be
       ((1U << 31) - 1) * 2 + 1)
     = (0x7fffffffU * 2 + 1)
     = 0xffffffffU

> But I now thought of a simpler definition.  _STDINT_MAX needs only
> two arguments, and can be simplified to:
> 
> /* _STDINT_MAX relies on the signedness of 'zero' to return the
>    correct type.  */
> #define _STDINT_MAX(bits, zero) (~ _STDINT_MIN (1, bits, zero))

Are you sure this will work for bits < 32? For example, for bits==16
it will evaluate to 0xffffffffU, not 0xffffU.

> OK, I'll change it to this, which follows the advice you gave:
> 
>    #define int_fast8_t long int
>    #define uint_fast8_t unsigned int_fast8_t
>    #define int_fast16_t long int
>    #define uint_fast16_t unsigned int_fast16_t
>    #define int_fast32_t long int
>    #define uint_fast32_t unsigned int_fast32_t

Thanks. That should be fine on all systems.

Bruno


Reply via email to