This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC 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: [RFH] A simple way to figure out the number of bits used by a long double


Hi, 
>> Huh.  I would have *sworn* that sizeof(long double) was 10 not 16
>> even though we know it was 80 bits.
normally, it's either 12, for 32-bit machines, or 16, for 64-bit
machines. In any case, there are padding bytes, which we don't want to hash.
>>
>> How about (in the language of numeric_limits):
>>
>> bits = 1     //  sign bit
>>      + ::digits    //  significand bits
>>      + log2(1 + ::max_exponent - ::min_exponent)  //  exponent bits
>>
>> There are preprocessor macros for each these things IIRC if you would
>> rather use those.
Thanks. Currently I'm thinking of doing something very simple, like:

    const size_t __size = __LDBL_MANT_DIG__ == 64 ? 10 : sizeof(__val);

seems conservative and I think it covers all the cases we really
support. But if people are aware of counterexamples, for the targets
actually supported by the C++ library, I'm all ears... No hurry, anyway,
we can tweak the above to take care of special cases whenever we want...

Paolo.


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