Re: Formatted IO of huge/tiny values
- From: glen herrmannsfeldt <gah@xxxxxxxxxxxxxxxx>
- Date: Wed, 22 Mar 2006 03:39:08 -0800
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.
> exponent range, so those bits are available as fraction bits.[...][...] Remember that fewer exponent bits are required for the same
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
.
- Follow-Ups:
- Re: Formatted IO of huge/tiny values
- From: Joe Krahn
- Re: Formatted IO of huge/tiny values
- From: James Giles
- Re: Formatted IO of huge/tiny values
- References:
- Formatted IO of huge/tiny values
- From: Janne Blomqvist
- Re: Formatted IO of huge/tiny values
- From: Richard E Maine
- Re: Formatted IO of huge/tiny values
- From: James Giles
- Re: Formatted IO of huge/tiny values
- From: Richard E Maine
- Re: Formatted IO of huge/tiny values
- From: James Giles
- Re: Formatted IO of huge/tiny values
- From: Joe Krahn
- Re: Formatted IO of huge/tiny values
- From: James Giles
- Re: Formatted IO of huge/tiny values
- From: glen herrmannsfeldt
- Re: Formatted IO of huge/tiny values
- From: Dan Nagle
- Re: Formatted IO of huge/tiny values
- From: glen herrmannsfeldt
- Re: Formatted IO of huge/tiny values
- From: Dan Nagle
- Re: Formatted IO of huge/tiny values
- From: glen herrmannsfeldt
- Re: Formatted IO of huge/tiny values
- From: James Giles
- Re: Formatted IO of huge/tiny values
- From: Dan Nagle
- Re: Formatted IO of huge/tiny values
- From: glen herrmannsfeldt
- Re: Formatted IO of huge/tiny values
- From: James Giles
- Formatted IO of huge/tiny values
- Prev by Date: Re: Will the *real* vms fortran please stand up? (historical questions)
- Next by Date: Re: how to eleminate the spurious ??
- Previous by thread: Re: Formatted IO of huge/tiny values
- Next by thread: Re: Formatted IO of huge/tiny values
- Index(es):
Relevant Pages
|
Loading