On 8/24/15 3:15 PM, bachmeier wrote:
On Monday, 24 August 2015 at 18:59:58 UTC, Steven Schveighoffer wrote:
All this gets down to: FP cannot accurately represent decimal. Should
this be fixed? Can it be fixed? I don't know. But I would be very
cautious about converting anything FP to integers without some epsilon.

-Steve

I don't see anything that needs to be fixed, because I don't think
anything is broken - there is nothing that violates my understanding of
floating point precision in D.

cast is not round. What is broken is a program that attempts to convert
a double to an integer type using a cast rather than the functions that
were written to do it correctly.

What is surprising, and possibly buggy, is that none of these operations involve real, but the issue only happens because under the hood, real is used instead of double for the multiplication.

I pretty much agree with you that the code is written incorrectly. But it is unfortunate it differs in the way it handles this from C. I think this issue has been brought up before on the newsgroup, especially where CTFE is involved.

-Steve

Reply via email to