Re: about c to fortran



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


.



Relevant Pages

  • Re: How wrong can you be with your NPV and MIRR functions in EXCel
    ... "Harlan Grove" wrote in message ... I always build up those calculations using simple ... > almost always retain greater precision and accuracy than any ... rounded to three or four significant figures depending on the client) ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Excel Bug - Excel Geeks Unite!!
    ... Will round all values to cell format precision. ... Rounding to a specified number of significant figures does not necessarily solve the problem (see my previous decimal example involving ... That situation was potentially frustrating to serious numerical analysts, since it meant that there was far more precision available than you were allowed to use. ... Given the nature of this issue, I would tend to distrust any current package that does not exhibit the normal effects of finite precision binary approximation, unless the reason is clearly documented. ...
    (microsoft.public.excel.misc)
  • Re: Is it time to legitimise REAL*8 etc?
    ... want/need to specify things. ... Decimal digits of precision might seem fine ... but that just isn't a good match the reality of programming. ...
    (comp.lang.fortran)
  • Re: Diophantine matters
    ... precision, say thirty decimal digits. ... the PSLQ algorithm is more recent, and therefore likely to be better ... Integer Relation Algorithm; RNR Technical Report RNR-91-032, July 14, ...
    (sci.math.symbolic)
  • Re: double is integer?
    ... decimal digits of precision, and every implementation I've seen is exact ... integer type in question) or fractions that it becomes imprecise. ... range of int/long while relieving you of overflow worries. ...
    (microsoft.public.vc.mfc)