[Issue 360] Compile-time floating-point calculations are sometimes inconsistent

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Sep 22 13:06:09 PDT 2006


http://d.puremagic.com/issues/show_bug.cgi?id=360


smjg at iname.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg at iname.com




------- Comment #7 from smjg at iname.com  2006-09-22 15:06 -------
(In reply to comment #5)
> const float A = 0.2;  // infinitely accurate 0.2, but type inference on A
> should return a float.
> 
> const float B = 0.2f; // a 32-bit approximation to 0.2
> const real C = 0.2; // infinitely accurate 0.2
> const real D = 0.2f; // a 32-bit approximation to 0.2, but type inference will
> give an 80-bit quantity.

I agree.  Only I'm not sure about A.  If you want it to be "infinitely
accurate", then why would you declare it to be a float?  It appears to me to be
a means by which a float can hold more precision than it really can.  On the
other hand, D should definitely generate a 32-bit approximation to 0.2.  By
using the 'f' suffix, this is exactly what the programmer asked for.


-- 




More information about the Digitalmars-d-bugs mailing list