This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFA: Fix signbit() for 16-bit targets


Hi Craig, Hi DJ,

+  return (w & 0x80000000) != 0;
Also 0x80000000 -> 0x80000000UL ?
Given that uint32_t is being used, UINT32_C(0x80000000) would seem most
appropriate, although this might mean stdint.h would have to be added.

In theory no cast is needed. According to the ISO C standard an integer constant has:

  6.4.4 (5)
    The type of an integer constant is the first of the corresponding
    list in which its value can be represented.

    Suffix   Decimal Constant
     none        int
                 long int
                 long long int

So for targets where "int" is 32-bits 0x80000000 will be an int, but for targets where "int" is 16-bits 0x80000000 will be a long int. (The signed-ness of the type should not matter here as we are only performing a binary operation on the value).

This also matches the practice. At least for the 16-bit RL78 toolchain compiled with GCC 4.8. The code, without a cast, works there.

Cheers
  Nick




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]