Float compare broke!

Dmitry Olshansky dmitry.olsh at gmail.com
Mon Jun 11 13:42:57 PDT 2012


On 11.06.2012 14:33, Era Scarecrow wrote:
> Most curiously while making unittests the asserts fail when I've
> confirmed it's working. The difference seems to be if it's
> immutable/const vs non, and why this makes a difference I don't see...
> Can someone give some light to this?
>
> const float i_f = 3.14159265;
Doesn't fit into float AFAIK. The rest "flows" naturally from here with 
a help of constfold-engine that prefers to keep precision intact 
(regardless of whether the type can actually hold it).

> float a = i_f;
> float b = i_f;
> assert(a==b); //passes
> assert(a==i_f); //fails


-- 
Dmitry Olshansky


More information about the Digitalmars-d-learn mailing list