Re: Formatted IO of huge/tiny values



James Giles wrote:

(snip regarding FLOAT DECIMAL)

Quite so. But, the proper algorithms for decimal are
much more complex than the algorithms for binary, and
take more operations. Even something as simple as
(X+Y)/2 will accumulate error maybe 3 to 5 times
as fast in decimal than in binary. Yes, there is a
way to rewrite the expression to keep decimal more
competitive (though it never wins), but in general it
requires more operations (maybe even a conditional).
If even such simple expressions need to be rewitten,
what of the kinds of thing real numerical computations
do?

The last iteration of a Newton-Raphson square root is
done as X+(X-Y)/2. (It is for hexadecimal, also.)
It might even be better in binary (the rounding can be different),
and it is just one more subtraction.

[...] Remember that fewer exponent bits are required for the same
> exponent range, so those bits are available as fraction bits.[...]

Well, it won't be so for the IEEE decimals. For example, the
IEEE single precision decimal carries 7 decimal digits and
an exponent range of + or minus 95. That means that the
size of one ULP compared to the number itself varies from
10^(-6) to 10^(-7) for such numbers. While the binary
IEEE single carries 24 bits and the relative size of one ULP
is between about 10^-(6.92) and about 10^(-7.22). More than
half the representable decimals have a worse relative error
than the worst that binary does.

So you don't give any value to the larger exponent range?
Binary floating point to get to +/-95 would have two fewer
fraction bits. Note also that in both cases you can't guarantee
seven digits.

(snip)

Yes, the binary representation has a narrower exponent range,
but fewer calculations run afowl of that than accumulated roundoff.

and many that don't probably should be done in fixed point, anyway.

[...] It is easier for most people to understand the effects
of decimal rounding and such, as most of us have been doing it longer.

Understanding why you're doing worse is no help if your
algorithm is unstable with decimal even though the same
algorithm is comfortably stable with binary.


It is usual to report results in journal articles in decimal, and the
precision effects of decimal haven't caused many problems there.

That's because results printed on a page are static. They
are the output of a program, not values of the ongoing
computation.

(snip)

Well, often they are the result of a series of calculations explicitly done in the article. Their is a long history of keeping sigfigs (significant figures) in calculations, that is, decimal digits.
I suppose one could have sigbits, but I haven't seen that yet.

I don't remember the numbers for double precision, but I believe they are somewhat better, and likely to be used much more (as it is in binary). I doubt binary will disappear. People will choose in any
case, though it does get complicated to mix them inside one program.

-- glen

.



Relevant Pages

  • Re: Computing decimals of pi
    ... N decimals one has to carry out all the intermediate ... computations to a precision of N decimals - which means that one ... It allows for base-16 digits of pi to be computed without ... You can't just run a spigot algorithm ...
    (sci.math)
  • Re: Computing decimals of pi
    ... N decimals one has to carry out all the intermediate ... computations to a precision of N decimals - which means that one ... It allows for base-16 digits of pi to be computed without ... You can't just run a spigot algorithm ...
    (sci.math)
  • Re: determining sqrt(2)..
    ... Could someone tell me some relatively easy way of determining the first ... I would need some kind of algorithm for doing it. ... expand to decimals at the end. ...
    (sci.math)
  • Re: storing values
    ... <SNIP FP evergreen... ... I really need to store the ... If you, for example, want just a few decimals after the dot ... numbers will not the sin() of what is originally intended. ...
    (comp.soft-sys.matlab)
  • RE: [PHP] Stripping Decimals
    ... if entered and reformat it as a price for an item. ... user not to use decimals but some still do. ...
    (php.general)

Loading