FloatingPoint in D

BCS ao at pathlink.com
Tue Mar 13 15:33:49 PDT 2007


Reply to Frits,

> 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?
>> 

<Justified but un-needed bashing of my memory> <G>

> The D spec page on floating point[2] specifies that all operations
> should comply with IEEE-754 rules (did you perhaps mean _that_
> standard?), 

yes

> 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)
> 

IEEE-754 does spec the bit pattern for 32 & 64 bit FP values

> 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=Sear
> ch&hl=en [2]: http://www.digitalmars.com/d/float.html
> 

real will be a pain however it's cut because even in x86 where it is 80bit 
IEEE-754 doesn't define an exact bit pattern.

So I'm thnking the result is: D floating point can be assumed to use IEEE-754.




More information about the Digitalmars-d-learn mailing list