Open klausler opened 2 years ago
A discussion on the J3 mailing list clarifies the questions that I had above. In short, the example results for TINY() & al. differ from what one will observe from any Fortran compiler for any modern architecture because the floating-point representation in subclause 16.4 differs from IEEE-754 32-bit finite numbers by a factor of two.
This should be fixed. At the very least, subclause 16.4 should be labeled with a disclaimer that, despite the close integration of the IEEE-754 standard for floating-point arithmetic with the rest of the Fortran standard, the model used to define and demonstrate ca. 15 intrinsic functions is not in fact IEEE-754 32-bit, but instead off by a factor of two.
A better solution would be to make either of the two adjustments to the model that I described above, change the example results accordingly, and forestall further confusion on the part of people actually trying to use this document due to what are by this point gratuitously weird discrepancies from a truly ubiquitous floating-point format.
In 32-bit IEEE-754 floating-point arithmetic, the smallest normal (full-precision) number is 2(-126) -- it has a biased exponent of -126 + 127 == 1 and only the implicit normalization bit set in its fraction. But F'2018 16.9.191 has the example TINY(0.0) == 2(-127) in the model floating-point representation of Note 1 in 16.4.
And that seems to be the case if you plug e=-127 and a zero fraction into Note 1's floating-point model. But that model, to minimize confusion, really should reflect the 32-bit IEEE-754 floating-point representation that is now ubiquitous. (The Note does not mention IEEE-754 explicitly.)
The standards can of course present examples with any floating-point model, but: if the model is not intended to be 32-bit IEEE-754, that note and all of the examples of intrinsic functions that refer to it should be marked with warnings that the model and the examples are not IEEE-754, to forestall confusion. Or the model, and all of the examples that refer to it, should be fixed to be 32-bit IEEE-754.
There are two ways to fix the model in Note 1. One is to replace "2 to the power of e" with "2 to the power of (e+1)". The other is to change the interpretation of the fraction to "(1 + sum ...)" and adjust the binary exponent in the summand.
There is also of course the chance that my understanding of the model is wrong. But I'm sure that example for TINY(0.0) is not right for default real with any Fortran compiler that I can access, running of course on computers with IEEE-754 floating-point arithmetic.