Very strange problem with comparing floating point numbers

Maxim Fomin maxim at maxim-fomin.ru
Mon Oct 1 22:45:42 PDT 2012


On Monday, 1 October 2012 at 21:23:31 UTC, monarch_dodra wrote:
> What I was saying is that for built in types such a floats, 
> "is" is (should be) no different from "==".
>
> But you catch something interesting: the fact that it provides 
> different results is (IMO), a bug. Looking at it, I'd say the 
> bug is probably that "==" is overly sensitive to extended 
> precision.
>
> I've filed a BR:
> http://d.puremagic.com/issues/show_bug.cgi?id=8745
>
> Please feel free to add anything to it. We'll see if Walter 
> will react to it for a more definite answer.

It looks like dmd uses x87 comparison instructions which are 
inexact comparing to is. So, similarity of is and == operators on 
built-in and user-defined types may be subject to 
float/double/real exception.


More information about the Digitalmars-d-learn mailing list