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

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

floating-point bug?


From: Linda Riewe
Subject: floating-point bug?
Date: Wed, 10 Nov 2004 15:21:53 -0800

Hello,

The following program should print "true" on ever line:

BEGIN {

 x = 3000 * 8.87
 y = 8.87 * 3000
 a = 3 * 8870
 b = 0.3 * 88700
 z = 26610.00
 w = 26610
 print "a=" a " b=" b " w=" w " x=" x " y=" y " z=" z
 print "x == y " ((x == y) ? "true" : "false")
 print "x == z " ((x == z) ? "true" : "false")
 print "x == a " ((x == a) ? "true" : "false")
 print "x == b " ((x == b) ? "true" : "false")
 print "x == w " ((x == w) ? "true" : "false")
}

but instead, it prints:

> gawk -f tryit
a=26610 b=26610 w=26610 x=26610 y=26610 z=26610
x == y true
x == z false
x == a false
x == b false
x == w false

The version is:

> gawk --version
GNU Awk 3.1.3

Thanks in advance for your response,

Linda


reply via email to

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