Path: utzoo!utgpu!watserv1!watmath!att!att!pacbell.com!mips!zaphod.mps.ohio-state.edu!usc!ucsd!ucbvax!F.ADELAIDE.EDU.AU!DDAVID From: DDAVID@F.ADELAIDE.EDU.AU Newsgroups: comp.sys.sgi Subject: Re: Another C compiler bug Message-ID: <901105134647.1282@F.ADELAIDE.EDU.AU> Date: 5 Nov 90 19:46:47 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 49 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