We need to clarify if 'real' is the 'default floating point type'or not.

Don Clugston dac at nospam.com.au
Mon Mar 3 13:25:59 PST 2008


BCS wrote:
> Reply to Don,
> 
> [good stuff removed]
> 
> this looks like a good cases for a pile of aliases (and the overloads 
> you mentioned).
> 
> alias for:
> 
> fast_*,   largest with much speed penalty
> best_*,  best supported HW_*,   w/ full HW support
> IEEE_*, IEEE compliant
> pow2_*, power of 2 length
> ...
> 
> these would be used like:  best_HW_IEEE_pow2_real (or something like that)

Well, IMHO, 'real' is a fine name for the largest without speed penalty. It's 
nice and short, and it sounds like a default type. The only other one you'd want 
is 'best_real' -- 'real' is viable for that, too, but names like longdouble and 
longreal come to mind.

One workable option would be to split the current 'real' type into real80, 
doubledouble, and quadruple (depending on the system) and then we had:

version(X86) { // more precisely, X86 using the X87 coprocessor
  typedef real80 real;
} else {
  typedef double real;
}

version(X86) {
  typedef real80 longreal;
} else version(PPC) {
  typedef doubledouble longreal;
} else version(Sparc){
  typedef quadruple longreal;
} else {
  typedef double longreal;
}

The interesting thing about those types is that they can be emulated on any 
system. On some systems, multiple options can be implemented efficiently. For 
example, on Itanium, you have 80-bit reals AND a fma instruction. So you can do 
real80, doubledouble, the funky internal itanium 81-bit real, and could even do 
a real80real80 type.



More information about the Digitalmars-d mailing list