[Issue 1681] New: cast(real) ulong.max == 0
Xinok
xnknet at gmail.com
Wed Nov 21 11:29:10 PST 2007
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.
d-bugmail at puremagic.com wrote:
> http://d.puremagic.com/issues/show_bug.cgi?id=1681
>
> Summary: cast(real) ulong.max == 0
> Product: D
> Version: 2.007
> Platform: PC
> OS/Version: Linux
> Status: NEW
> Severity: normal
> Priority: P2
> Component: DMD
> AssignedTo: bugzilla at digitalmars.com
> ReportedBy: andrei at metalanguage.com
>
>
> The title says it all. Here's a test:
>
> import std.stdio;
> import std.conv;
>
> void main()
> {
> real r = ulong.max;
> ulong d = cast(ulong) r;
> writeln(d);
> assert(d == ulong.max); // should not fail
> }
>
>
More information about the Digitalmars-d-bugs
mailing list