Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!sun-barr!cs.utexas.edu!uunet!mcvax!ukc!strath-cs!nott-cs!ucl-cs!S.Usher From: S.Usher@ucl-cs.UUCP Newsgroups: comp.sys.atari.st Subject: Sozobon C bug report Message-ID: <328@ucl-cs.UUCP> Date: 7 Jul 89 14:04:42 GMT Sender: S.Usher@ucl-cs.UUCP Lines: 38 From: Stephen Usher I have just found an unfortunate bug with Sozobon C. If you divide using long integers you sometimes get a negative result, even when both the integers have positive values. The piece of code which highlighed the bug is part of a program which emulates the UN*X MORE program. It's actual function is to work and display the percentage of the file so far seen. Here is a code segment. static long endoffile, bytes = 0, topbytes; endoffile = endof(fp); topbytes = bytes; if (fp != stdin) printf("(%ld%%)", ((bytes * 100) / endoffile)); long endof(fp) FILE *fp; { return (lseek(fileno(fp), 0L, 2)); } The variable "bytes" is always incremented and, therefore, can never become negative, so topbytes can never become negative (topbytes holds the file position of the top of the screen). Stephen Usher Addresses:- (JANET) S.Usher@uk.ac.ucl.cs or UCACMSU@uk.ac.ucl.euclid --8<-------------- Cut --------------------- Here ------------------------