Complex number functions for std.math

Anders F Björklund afb at algonet.se
Mon Apr 10 03:11:50 PDT 2006


Don Clugston wrote:

> I think it doesn't matter much what it is called. It should almost never 
> appear in code. (Code that uses it is CPU-specific, so some low-level 
> library code like isfinite() will use it, but not much else). User code 
> should almost always use "real".

Sounds good to me. Bringing back imaginary and complex would be enough,
then user code could use "real" and "complex" and not worry about it...
Like you mentioned, that's simple to do by using alias in the interim.

Any "extended" and "quadruple" would only be in lowlevel future layers.
("real" would automatically alias to type double, extended or quadruple)
If they're not used much, maybe they don't even need any "short forms".

> (Arguably, they could even be called float80_80 for Windows, float80_96 
> for Linux32, float80_128 for Linux64, because of the differences in 
> padding. 

Then again, on any single platform you would only encounter one of them?
For instance "register" variables holding them would be the same on all.

Cross-platform data would be more work, but could use different padding.
(i.e. storing/reading 10 bytes, and adjust the padding according to ABI)

> The Linux64 format is binary compatible with the IEEE quadruple 
> format; it behaves identically to a quad where the precision has been 
> set low).

Interesting, hadn't thought of that... But it's very good news I think.
(Mac uses the same 128-bit format, in the Intel ABI for Mac OS X 10.4)

It's cool because you can then use the quad format for data exchange,
even if neither PowerPC/Intel will use it internally. (just 64+64/80)

--anders



More information about the Digitalmars-d mailing list