Another C compiler bug
DDAVID at F.ADELAIDE.EDU.AU
DDAVID at F.ADELAIDE.EDU.AU
Tue Nov 6 06:46:47 AEST 1990
Martin Fong writes:
>I get the following results on the following MIPS-based systems:
>
> RISC ULTRIX 3.0 7e-7 = 0.000000
> SGI IRIX 3.2 7e-7 = 0.000000
> MIPS OS 1.0 7e-7 = 0.000001
>
>Looks like yet another compiler bug which MIPS has fixed but DEC and
>SGI have not yet picked up.
>
This is another example of the following:
This test program
main() {
float x;
while (1) {
printf("input x : ");
scanf("%f", &x);
printf("x = %f -> %.0f\n", x,x);
}
}
produces the following output (Irix 3.3.1) :
x = 0.2 -> 0
x = 0.6 -> 0 ??
x = 0.95 -> 0 ??
x = 0.99 -> 1 ????
x = 1.2 -> 1
x = 1.6 -> 2
x = 2.2 -> 2
x = 2.6 -> 3
x = -1.6 -> -2
x = -1.20 -> -1
x = -0.99 -> -1 ????
x = -0.90 -> 0 ??
x = -0.60 -> 0 ??
x = -0.2 -> 0
so you can see that printf is not consistent in rounding to the nearest
number for floating point numbers between -1 and 1.
A minor bug but annoying. I hope it is fixed in the next release.
Regards,
David Netherway,
Australian Cranio-Facial Unit
More information about the Comp.sys.sgi
mailing list