[Issue 1681] cast(real) ulong.max == 0

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Nov 21 12:44:42 PST 2007


http://d.puremagic.com/issues/show_bug.cgi?id=1681





------- Comment #3 from wbaxter at gmail.com  2007-11-21 14:44 -------
(In reply to comment #2)
> (In reply to comment #1)
> > Real is a floating point type, typically 80 bits. Ulong is a 64-bit 
> > integer type. Real is not capable of holding a value as large as 
> > ulong.max. That is why the assert fails.
> 
> Float must store integers with proper successors up to 2 ** 24 - 1. Double must
> store integers with proper successors up to 2 ** 53 - 1. Real (i.e.
> "double-extended") must store integers with proper successors up to at least 2
> ** 64 - 1. The program prints 0.
> 

This is also interesting:

    writefln("ulong.max      %-30d", ulong.max);
    writefln("real ulong.max %-30f", cast(real)ulong.max);

-->

ulong.max      18446744073709551615          
real ulong.max 18446744073709551613.000000   


-- 



More information about the Digitalmars-d-bugs mailing list