Questions about IEEE754 floating point in D

Don nospam at nospam.com
Tue Feb 23 10:57:33 PST 2010


Walter Bright wrote:
> Lars T. Kyllingstad wrote:
>> Don wrote:
>>> I have a vague recollection that this bizarre definition is for 
>>> compatibility with an ancient mistake in C. Some clown miscalculated 
>>> it, and by the time people realized, they felt it was too late to fix 
>>> it.
>>
>> Then it sounds like something D should get right.
> 
> There's a problem with that - porting working C numerics code to D.

That's not a concern. The syntax is completely different, so it always 
requires thought. We could perhaps define float.min_2_exp with the 
correct value (by analogy with float.min_10_exp) and get rid of .min_exp.

If porting C code mechanically, you'll just import core.stdc.float_;
It contains the line:

enum DBL_MIN_EXP		= double.min_exp;

which could be changed to:

enum DBL_MIN_EXP = double.min_2_exp + 1;

It's not a big deal, but it's certainly something we could fix.



More information about the Digitalmars-d mailing list