[comp.sys.next] Bug in awk?

burns@gatech.edu (James E. Burns) (09/30/90)

I have encountered what seems to be a bug in awk on the NeXT.
(I am using an original Cube with Version 1.0 software.)
The following awk script works correctly on Sun and Sequent
but gives the results as shown on NeXT:

#junk.awk  --- a bug demonstration
BEGIN {w=14582641; l=2754258; t=204911}
{}
END {s = w+l+t
     v = w+t+l
     print w,l,t,s,v
    }

NeXT output:
14582641 2754258 204911 17541812 17541810

Correct output:
14582641 2754258 204911 17541810 17541810

This looks like an overflow problem, but I haven't been
able to pin it down.  Does anyone know what is going on?
My confidence in using awk for grade computations is
dropping rapidly!

jim burns
--
James E. Burns    Associate Professor    (404) 894-3816
College of Computing, Georgia Tech, Atlanta GA 30332-0280
Internet :  burns@CC.GATech.edu  
uucp:	...!{akgua,allegra,hplabs,ihnp4,linus,seismo,ulysses}!gatech!cc!burns

henry@zoo.toronto.edu (Henry Spencer) (10/02/90)

In article <BURNS.90Sep30092040@bobcat.gatech.edu> burns@gatech.edu (James E. Burns) writes:
>I have encountered what seems to be a bug in awk on the NeXT. ...
>NeXT output:
>14582641 2754258 204911 17541812 17541810
>
>Correct output:
>14582641 2754258 204911 17541810 17541810
>
>This looks like an overflow problem, but I haven't been
>able to pin it down.  Does anyone know what is going on?

Looks like some mental defective has compiled awk to use "float" rather
than "double" for its numbers.  I thought that went out with the pdp11.
(On the 11 it made sense, because of limited address space.)  Notice that
trouble sets in once the numbers get too big for 24 bits, which is the
size of an IEEE single-precision ("float" in C-speak :-)) mantissa.
-- 
Imagine life with OS/360 the standard  | Henry Spencer at U of Toronto Zoology
operating system.  Now think about X.  |  henry@zoo.toronto.edu   utzoo!henry