www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - How to deal with systems where real == double

reply Johannes Pfau <nospam example.com> writes:
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)?

* 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.

* What about phobos functions overloads using "real"? Should those be
  disabled completely or should they call the "double" equivalent
  function?
Apr 28 2013
parent reply "Peter Alexander" <peter.alexander.au gmail.com> writes:
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.
Apr 28 2013
parent Walter Bright <newshound2 digitalmars.com> writes:
real is defined to be the largest floating point type supported on the target 
machine, so if that's the same as double, then it's double (though still a 
distinct type to the D typing system).
Apr 29 2013