Real Close to the Machine: Floating Point in D

Don nospam at nospam.com
Fri May 8 21:40:29 PDT 2009


bearophile wrote:
> Thanks to Don for the very nice explanation. I'll need more time to digest it all.
> 
> I can see that D2 is one of the best (maybe the best at the moment) language regarding its management of floating point values. This means that people interested in doing numerical FP computations may become interested in D2. But for them D may enjoy becoming a bit less "system language" and a bit more "scientific language", especially regarding tiling loops, matrix and domain management, automatic management of some data parallelism that is currently nearly totally absent, etc. (see Chapel language).
> 
>> A more advanced usage, not yet supported on any platform(!) is to provide a nested function to be used as a hardware exception handler.<
> 
> I didn't know this.

The hardware supports it, but unfortunately, there's no standardisation 
between OSes. Even on x86, it's requires a totally different technique 
for Windows compared to Linux (it's easier on Windows). And there's a 
problem with x87: given
FLOP1
xxx
FLOP2
where FLOP1 and FLOP2 are floating-point operations, if FLOP1 generates 
an exception condition, the exception doesn't actually happen until 
FLOP2! So the intervening xxx instructions are a big problem.
So it's usable only in very limited circumstances. Most likely, we won't 
be able to do more than provide a few library functions that make use of it.

>> real NaN(ulong payload) -- create a NaN with a "payload", where the payload is a ulong.<
> 
> - How many bit can reliably be stored there?
It's in the docs for NaN().
> - That function returns a real, but can payloads can be stored in doubles too?
Yes.
> - If doubles too can be used, how many bits long can be such payload?
> - Can Don give me one or two example usages of such payloads? (I have never seen them used so far in any language.)
> 
> Bye and thank you,
> bearophile



More information about the Digitalmars-d mailing list