bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: printing big decimals


From: Stepan Kasal
Subject: Re: printing big decimals
Date: Tue, 25 Mar 2003 11:34:44 +0100
User-agent: Mutt/1.2.5.1i

Hello,

On Tue, Mar 25, 2003 at 11:34:59AM +0200, Aharon Robbins wrote:
> %d -> %.0f makes sense, but I haven't thought about it yet in the

presenting floats as integers may be confusing.

Observe:
$ ./gawk 'BEGIN{OFMT="%.0f"; print 12e305}'
119999999999999992710426300664375462320483446641407899438289
258855878454756158806834119711089286092981242273416673946070
944606324911632366362829586090402593299847617300184132492812
523037949290870124637630582619188919676190609861991914589347
235295397664152419023950868876891252570151518344898852177657
7249280

I'd say that if gawk doesn't know the exact value, it should
warn you by the "%g" format.
(Unless gawk switches to arbitrary precision integers. But
that would be against its tradition, I guess.)

BTW, here is another strangely looking side effect of the default
setup:

$ ./gawk 'BEGIN{print 1200000.1}'
1.2e+06
$ ./gawk 'BEGIN{print 1200000.1 * 10}'
12000001

But I have no idea how this should be fixed, so I'd leave it as it is.

Have a nice day,
        Stepan Kasal




reply via email to

[Prev in Thread] Current Thread [Next in Thread]