On Monday, 24 August 2015 at 19:23:44 UTC, Steven Schveighoffer wrote:


real y = x * 10.0;
writeln(y.to!ulong); // 11

to! does not do anything different than cast. What is happening here is the implicit cast from real to double. D treats the result of x * 10.0 as type double, but it's done at real precision. In that conversion, the error is hidden by a rounding automatically done by the processor I think.

-Steve

Yes, I was mistaken. You have to use roundTo or std.math.round. to! and cast both truncate.

Reply via email to