FloatingPoint in D

Frits van Bommel fvbommel at REMwOVExCAPSs.nl
Tue Mar 13 13:26:30 PDT 2007


BCS wrote:
> Can any D implementation be assumed to use IEEE-768? In other words: can 
> I safely build floats and double from bits and expect it to work on an 
> arbitrary compiler including ones that don't exits yet?
> 
> I guess a corollary is, are there any platforms that D is likely to be 
> used on that have a hardware FP system *other* than IEEE-768?

There is exactly one Google hit for '"ieee 768" floating point'[1], 
which to me indicates one of two possibilities:
1) It's a _really_ unpopular standard ;).
2) There is no such thing as IEEE-768 or it has nothing to with floating 
point, and either (a) there is approximately one other person who 
thinks, like you, there is or (b) approximately nobody else thinks so 
and your name is Steve Harris ;).
(All of this, of course, assumes Google is correct in finding no more 
matches, which may or may not be true :P)

The D spec page on floating point[2] specifies that all operations 
should comply with IEEE-754 rules (did you perhaps mean _that_ 
standard?), but AFAICT that page doesn't actually specify the format of 
values when stored in memory. So unless a specific storage format is 
required by IEEE-754, assuming any particular binary format may not be 
portable. (Note: I have no idea what IEEE-754 specifies, exactly)

Also, there was also some mention a while back that GDC always defines 
'real' as the local C 'long double' type, which in the case of the port 
for PPC turns out to be a weird format consisting of two doubles used to 
represent a single value. There was some discussion regarding what to do 
about this, but I can't offhand remember the outcome. IIRC it was in 
D.gnu, in the announcement thread for GDC 0.23.


[1]: 
http://www.google.com/search?q=%22ieee+768%22+floating+point&btnG=Search&hl=en
[2]: http://www.digitalmars.com/d/float.html


More information about the Digitalmars-d-learn mailing list