How to deal with systems where real == double

Peter Alexander peter.alexander.au at gmail.com
Sun Apr 28 03:33:15 PDT 2013


On Sunday, 28 April 2013 at 08:39:47 UTC, Johannes Pfau wrote:
> How do we want to deal with systems which have no floating 
> point type
> bigger than double?
>
> * What's the proper check to detect this in druntime / phobos?
>   (real.sizeof == double.sizeof) or (real.mant_dig == 
> double.mant_dig)?

First should be sufficient, but I suppose both if you want to 
account for some hypothetical machine where the sizes are the 
same, but have a different number of mantissa bits.


> * Should the long double functions (tanl, cosl) be available 
> from
>   druntime? If so we need to alias them. Glibc does not provide 
> the
>   long double functions on a target without long double.

I think they should be available and just use the double 
versions. I don't see much point in needlessly breaking code that 
uses reals when they're the same as doubles.


> * What about phobos functions overloads using "real"? Should 
> those be
>   disabled completely or should they call the "double" 
> equivalent
>   function?

They should be aliases to the double versions or just call them. 
Not sure which, but we definitely should not just disable those 
overloads otherwise we just break code that uses reals 
unnecessarily.


More information about the Digitalmars-d mailing list