Printing shortest decimal form of floating point number with Mir

Ola Fosheim Grøstad ola.fosheim.grostad at gmail.com
Mon Jan 4 09:32:03 UTC 2021


On Monday, 4 January 2021 at 05:58:09 UTC, Walter Bright wrote:
> On 1/3/2021 8:37 PM, 9il wrote:
>> I didn't believe it when I got a similar answer about IEEE 
>> floating-point numbers: D doesn't pertinent to be IEEE 754 
>> compatible language and the extended precision bug is declared 
>> to be a language feature.
>
> The "extended precision bug" is how all x87 code works, C to 
> C++ to Java. The reason is simple - to remove the problem 
> requires all intermediate results to be written to memory and 
> read back in, which is a terrible performance problem. Early 
> Java implementations did this write/read, and were forced to 
> change it.
>
> The advent of the XMM registers resolved this issue, and all 
> the x86 D compilers now use XMM for 32 and 64 bit floating 
> point math, when compiled for a CPU that has XMM registers. 
> Extended precision only happens when the `real` 80 bit type is 
> used, and that is IEEE conformant.


But you still have to deal with things like ARM, so maybe the 
better option is to figure out what the differences are between 
various hardware and define "floating point conformance levels" 
that library can test for, including what SIMD instructions are 
available. For instance, the accuracy of functions like 
log/exp/sin/cos/arcsin/… can vary between implementations. It 
would be useful for libraries to know.





More information about the Digitalmars-d-announce mailing list