| |
| Posted by Russ Lewis in reply to Walter | PermalinkReply |
|
Russ Lewis
Posted in reply to Walter
| Walter wrote:
> Ah, on linux. I'll check it out.
I am on Linux (Fedora Core 1, DMD 0.110), and have found this problem with casting float->ulong, double->ulong, and real->ulong. It works when converting to long, however.
> import std.stdio;
> void main() {
> double d = 1.0;
> writefln("double: ",d);
> writefln("double->float: ", cast(float)d);
> writefln("double->real: ", cast(real)d);
> writefln("double->ulong: ", cast(ulong)d);
> writefln("double->long: ", cast(long)d);
> float f = 2.0;
> writefln("float: ",f);
> writefln("float->double: ", cast(double)f);
> writefln("float->real: ", cast(real)f);
> writefln("float->ulong: ", cast(ulong)f);
> writefln("float->long: ", cast(long)f);
> real r = 3.0;
> writefln("real: ",r);
> writefln("real->float: ", cast(float)r);
> writefln("real->double: ", cast(double)r);
> writefln("real->ulong: ", cast(ulong)r);
> writefln("real->long: ", cast(long)r);
> }
This currently prints:
> double: 1
> double->float: 1
> double->real: 1
> double->ulong: 0
> double->long: 1
> float: 2
> float->double: 2
> float->real: 2
> float->ulong: 0
> float->long: 2
> real: 3
> real->float: 3
> real->double: 3
> real->ulong: 0
> real->long: 3
|