floating point conversion

Martin Krejcirik via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Jun 1 14:55:09 PDT 2014


On 1.6.2014 18:02, Famous wrote:
> This is different. The decimal 1.234 cannot be exacly represented as
> radix-2 floating-point number. In your example above, a and b are not
> equal. They are both approximations to 1.234 but the value of b is

Still feels iffy to me. If you add:

   printf("%.70f\n%.70f\n", a, cast(float) b);

you can see that gcc in C and gdc in D both convert value of b to float
resulting in equality. Dmd doesn't, it just ignore the cast.

-- 
mk


More information about the Digitalmars-d-learn mailing list