Re: about c to fortran
- From: "James Giles" <jamesgiles@xxxxxxxxxxxxxxxx>
- Date: Mon, 19 Dec 2005 20:00:49 GMT
Giorgio Pastore wrote:
> wakun@xxxxxxxxx wrote:
> ...
>> The output is
>> C: 5.55540201833978480000 3.14159265358979310000
>> FORTRAN: 5.55540210790892086123 3.14159265358979311600
....
> [...]. The second one, more evident in the second value in
> your example, is that double or double precision data cannot have
> more than 16 significant figures of precision. So, it is pointless
> to print more.
This is not correct. In order that ouput followed by input
be the identity operation (that is, you get the same internal
value you wrote) you must usually write more than 16
decimal digits. The proper equation is:
10**(d-1) > 2**b
Where d is the number of decimal digits you write and
b is the number of bits in your binary significand. For IEEE
double precision, the value of b is 53. Since 2**53 is
about 9e15 d must be at least 17. Unless you have
specific reasons, or never plan to use the output number
as input to another program, you shoulod always choose
to write at least that many digits. I just wish list-directed
I/O did so on more implementations.
--
J. Giles
"I conclude that there are two ways of constructing a software
design: One way is to make it so simple that there are obviously
no deficiencies and the other way is to make it so complicated
that there are no obvious deficiencies." -- C. A. R. Hoare
.
- Follow-Ups:
- Re: about c to fortran
- From: glen herrmannsfeldt
- Re: about c to fortran
- References:
- Re: about c to fortran
- From: Giorgio Pastore
- Re: about c to fortran
- Prev by Date: Re: writing negative zero
- Next by Date: Re: writing negative zero
- Previous by thread: Re: about c to fortran
- Next by thread: Re: about c to fortran
- Index(es):
Relevant Pages
|