(j3.2006) reading 0x1.8000p+0
Bill Long
longb
Fri Oct 5 12:46:29 EDT 2007
Malcolm Cohen wrote:
> 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.
>
A kludge for writing, but does not work at all for reading. There is no
point in making users implement awkward workarounds when the much
simpler solution is "obvious". There is a reason this extension was
implemented in compilers.
> But that doesn't achieve the same goal, if one thinks the goal is
> in fact to get a hexadecimal floating-point number.
The goal is to make sure the value read is exactly the same as the one
written previously. Since this is almost always done in an environment
where the same system does both the write and read, it works just fine.
It has been working in actual practice for years. Decades probably.
> 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.
>
>
I'm always open to ways of getting around the hideous TRANSFER wart.
This 1.8000z+0 style option does not help in some of the cases where Z
format output is useful, but it could be useful. If the internal
representation is decimal, it might be anti-useful.
Cheers,
Bill
--
Bill Long longb at cray.com
Fortran Technical Support & voice: 651-605-9024
Bioinformatics Software Development fax: 651-605-9142
Cray Inc., 1340 Mendota Heights Rd., Mendota Heights, MN, 55120
More information about the J3
mailing list