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

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

Re: gawk bug in reporting formatted numbers


From: Hans-Bernhard Broeker
Subject: Re: gawk bug in reporting formatted numbers
Date: 2 Aug 2005 11:43:38 GMT

fuad badrieh <address@hidden> wrote:

> echo "0.2625e-6" | gawk 'BEGIN{OFMT="%9.3f"}{print $1*1e6}'
[...]

> The 25 should have been rounded to 3.

If it actually was 25: yes.  But it isn't, as you'll find out for
yourself once you change your OFMT to %9.20f and repeat the
experiment.

> If I run the same thing through a C program it does print 0.263

> #include <stdio.h>

> int main() {
> float x=0.2625e-6;
> printf("%9.3f\n", x*1e6);
> }

Use a double, not a float, and you'll see a difference.

-- 
Hans-Bernhard Broeker (address@hidden)
Even if all the snow were burnt, ashes would remain.




reply via email to

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