AWK bug; conditional test incorrect

Bug #650675 reported by InsaneBeast
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
original-awk (Ubuntu)
New
Undecided
Unassigned

Bug Description

Binary package hint: original-awk

*When evaluating very small numbers, awk will return the wrong value for a conditional test. A reproducible example of this bug follows. In this example the number 1.406605e-319 is compared to the number 1, 1e-4, and 1e-5. In all cases 1.406605e-319 is the smaller value, yet the result returned by the conditional test changes:

$ echo 1.406605e-319 |awk '($1<1){print "lower"} ($1>1){print "higher"}'
higher
$ echo 1.406605e-319 |awk '($1<1e-4){print "lower"} ($1>1e-4){print "higher"}'
higher
$ echo 1.406605e-319 |awk '($1<1e-5){print "lower"} ($1>1e-5){print "higher"}'
lower

*In this second example, 1e-319 is compared to the number 1, 1e-5, and 1e-50. In the previous example, comparing 1.406605e-319 with 1e-5 returned the correct result from the conditional statement. However, in this example comparing 1e-319 with 1e-5 no longer returns the correct value.

$ echo 1e-319 |awk '($1<1){print "lower"} ($1>1){print "higher"}'
higher
$ echo 1e-319 |awk '($1<1e-5){print "lower"} ($1>1e-5){print "higher"}'
higher
$ echo 1e-319 |awk '($1<1e-50){print "lower"} ($1>1e-50){print "higher"}'
lower

This bug is also reproducible in gawk. Interestingly, mawk seems to handle all comparisons correctly.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.