(j3.2006) reading 0x1.8000p+0
Malcolm Cohen
malcolm
Thu Oct 4 22:10:18 EDT 2007
On Fri, 05 Oct 2007 04:16:15 +0900, Bill Long <longb at cray.com> wrote:
> It is in the fprintf section (7.19.6.1), conversion specifier "a". The
> output is a double written using hex rather than decimal. The intent is
> to be able to exactly represent the internal bits of a double, avoiding
> rounding that occurs with decimal conversion. I've never actually seen
> it used, but it is documented in the standard. In Fortran (08 at
> least), we can accomplish the same goal by writing / reading the real
> value with Z format.
Or by TRANSFER-ing it to a 64-bit integer and Z-ing that.
But that doesn't achieve the same goal, if one thinks the goal is
in fact to get a hexadecimal floating-point number. I would think
that that *IS* the goal in this case (it is certainly the goal of
the C standard).
And it (TRANSFER+Z or the yukky F2008 Z) doesn't achieve even
Bill's goal if the internal number format differs (which can happen,
even within IEEE - think of the various extended formats). Writing
it actually as a hexadecimal floating-point string DOES achieve that
goal, even cross-format, with the (obvious) proviso that the number is
representable in the target format.
Supporting hexadecimal (or octal) floating-point conversions, viz
something like
1.8000z+0
(or even with p+0) would be a useful thing to do independently of C
interoperability, and is something that has been asked for. IMO it
is certainly more useful than an additional way of writing TRANSFER.
Cheers,
--
Malcolm Cohen, Nihon Numerical Algorithms Group KK, Tokyo, Japan.
More information about the J3
mailing list