bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] Awk cannot properly deal with too small numbers.


From: Wolfgang Laun
Subject: Re: [bug-gawk] Awk cannot properly deal with too small numbers.
Date: Fri, 15 Apr 2016 02:21:12 +0200

Note that this works:

$ echo 1.1e-309 | awk '$1+0 < 0.05{ print $1;}'
1.1e-309

Because of this

$ echo 1.1e-309 | awk '$1 < 2.05{ print $1;}'
1.1e-309

and similar experiments I'd call the difference in behaviour surprising.

-W



On 15 April 2016 at 01:31, david kerns <address@hidden> wrote:

You're hitting the limits of double precision floating point ... perhaps awk could issue a warning when your "out of bounds" string is coerced into a number that becomes zero, but I'm guessing the community will vote no.

On Thu, Apr 14, 2016 at 9:44 AM, Zhengyu Guo <address@hidden> wrote:
Hi,

I encountered a problem when dealing with very small numbers. The test case this shown below

~~~
$ echo 1.1e-307 | awk '$1<0.05{print}'
1.1e-307
$ echo 1.1e-309 | awk '$1<0.05{print}’
~~~

Both commands should print out the input number. However, the second command print out nothing. 

It seems that when the numeric number is too small, AWK cannot process it correctly. 

Thanks!



reply via email to

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