log2 buggy or is a real thing?

Don Clugston dac at nospam.com
Wed Apr 4 11:18:25 PDT 2012


On 04/04/12 18:53, Timon Gehr wrote:
> On 04/04/2012 05:15 PM, Don Clugston wrote:
>>
>> I don't think so. For 80-bit reals, every long can be represented
>> exactly in an 80 bit real, as can every ulong from 0 up to and including
>> ulong.max - 1. The only non-representable built-in integer is ulong.max,
>> which (depending on rounding mode) gets rounded up to ulong.max+1.
>>
>
> ?
>
> assert(0xffffffffffffffffp0L == ulong.max);
> assert(0xfffffffffffffffep0L == ulong.max-1);

Ah, you're right. I forgot about the implicit bit. 80 bit reals are 
equivalent to 65bit signed integers.

It's ulong.max+2 which is the smallest unrepresentable integer.

Conclusion: you cannot blame ANYTHING on the limited precision of reals.


More information about the Digitalmars-d-learn mailing list