Philip Potter wrote:
2009/11/4 David Lee <david....@ecmwf.int>:
[...]
Anyway, your explanation was useful and gives us sufficient to decide how to
address our local use of these numbers. (In our case, they are
human-oriented accumulated byte-counts, for which we don't actually need
that significance/precision.)
Really? If it's an accumulator, you can get into trouble:
p...@tui:~$ perl -e 'my $i = 1e16; for (1..10) { printf "%.17g\n",++$i; }'
10000000000000000
10000000000000000
10000000000000000
10000000000000000
10000000000000000
10000000000000000
10000000000000000
10000000000000000
10000000000000000
10000000000000000
remember even if you don't care about printing the right value, you
have to ask if you need to store the right value. Better hope you're
always adding large powers of two to that accumulator. And it's so
easy to use a datatype which does the Right Thing, why not use it?
Thanks.
In fact, I had already realised that, but my earlier reply email
inadvertently didn't acknowledge that known distinction, namely between:
(1) how to perform the accumulation where, as you say, we certainly
need to consider such issues (lots of relatively small increments to a
growingly huge number) and:
(2) how to present that information in its various outputs (which is
where I had initially been "surprised"...)
All the best.
--
: David Lee
: ECMWF (Data Handling System)
: Shinfield Park
: Reading RG2 9AX
: Berkshire
:
: tel: +44-118-9499 362
: email: david....@ecmwf.int
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/