Re: compilation problem with module function interface definition



glen herrmannsfeldt wrote:
> James Giles wrote:
....
> Storing three digits in 10 bits, with additional BCD digits when
> the number of digits is not a multiple of three is only slightly
> less efficient than pure binary. For a given range, fewer exponent
> bits are needed, which pretty much makes up for the lost bits due
> to decimal normalization.

Well, sort of. The IEEE proposed decimal float will store seven
digits. While comparing precision of representations with different
bases is difficult, one measure is the relative spacing between
representable values. In the 7 digit decimal, the relative spacing
varies from one part in ten to the seventh all the way to one part
in ten to the sixth. Meanwhile, with the 24-bit binary representation,
the relative spacing varies between one part in two to the twenty-
fourth and one part in two to the twenty-third - that's almost
twice as good as the finest end of the seven digit decimal for
some values and only a little worse than the finest end of the
seven digit decimal at worst. So, the binary is, on average,
better precision. But, even more to the point, even if the decimal
were slightly better on average, the wide variation makes it less
appealing numerically. Mixed mode between binary and decimal
of approximately the same precisions should probably result in
binary for best results.

Unfortunately, Fortran makes the reverse decision. I looked it
up and the standard specifies that mixed-KIND expressions will
result in the KIND that carries the most precision as defined by
the PRECISION intrinsic function. The precision is defined there
as INT( (p-1) + LOG10(b)) + k. Here, b is the base, p is the number
of base-b digits, and k is zero unless b is a multiple of 10, in which
case k is one. This use of k has the effect of comparing the relative
spacing of non-decimal KINDs at the worst part of their range to
the relative spacing of decimal KINDs at the best part of their range.
And the fact that the result is truncated to an INT further penalizes
non-decimal KINDs. By this formula, 24-bit binary has a precision
of 6 while 7 digit decimal has (obviously) a precision of 7. But,
comparing apples to apples, the widest relative spacing of the
binary carries about 6.92 decimal-equivalent digits and the widest
relative spacing of the decimal carries only 6.

--
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: compilation problem with module function interface definition
    ... While comparing precision of representations with different ... In the 7 digit decimal, the relative spacing ... the widest relative spacing of the binary carries about 6.92 decimal-equivalent digits and the widest relative spacing of the decimal carries only 6. ...
    (comp.lang.fortran)
  • Re: float bug? perl 5.8, DBI and oracle 10.2.0
    ... precision numbers in oracle, you've got 38 decimal digits to play ... and with minimal coaxing perl will handle them as ... digits from a 32 bit floating point number - I'll go out on a limb ... and hazard that one can expect 12 or so digits from a 64 bit floating ...
    (perl.dbi.users)
  • RE: float bug? perl 5.8, DBI and oracle 10.2.0
    ... I would not characterise 32-bit signed integers as giving 10 digits ... truncate and tell people you get 9 digits of precision. ... perl 5.8, DBI and oracle 10.2.0 ... Floating point values are typically stored in 64 bits or sometimes 96 ...
    (perl.dbi.users)
  • Re: float bug? perl 5.8, DBI and oracle 10.2.0
    ... I would not characterise 32-bit signed integers as giving 10 digits ... truncate and tell people you get 9 digits of precision. ... perl 5.8, DBI and oracle 10.2.0 ... Floating point values are typically stored in 64 bits or sometimes 96 ...
    (perl.dbi.users)
  • Re: 15 Significant Digits Limitation a Mistake for Spatial Informa
    ... DP does not restrict to 15 decimal digits. ... Input and output precision are more tightly linked in Excel ... Decimal data type or roll your own extended precision data types. ...
    (microsoft.public.excel)