🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.micro.atari16
Article #1598

Division problem with Lattice C

#1598
From: Opstad.osbunorth
Date: Sun, 24 Aug 1986 18:52
20 lines
1079 bytes
  I discovered this little problem while writing a prime factorization
program. Consider the following fragment:
  
  unsigned long i;
  i = 16777216L;
  printf("%ld\n", i);
  i /= 2;
  printf("%ld\n", i);
  
  Imagine my surprise when the same number is printed by both printf
calls! When I changed the fourth line to:
  
  i >>= 1;
  
  the program worked fine and printed the correct results. Has anyone
else had problems with division using Lattice/Metacomco C? (I'm using
version 3.03.04)
  
  Dave Opstad (Opstad.osbunorth@Xerox.COM)
Technical Details
Message-ID: <860824-115320-1121@Xerox>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!lll-crg!nike!ucbcad!ucbvax!Xerox.COM!Opstad.osbunorth

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!lll-crg!nike!ucbcad!ucbvax!Xerox.COM!Opstad.osbunorth
From: Opstad.osbunorth@Xerox.COM
Newsgroups: net.micro.atari16
Subject: Division problem with Lattice C
Message-ID: <860824-115320-1121@Xerox>
Date: Sun, 24-Aug-86 14:52:53 EDT
Article-I.D.: Xerox.860824-115320-1121
Posted: Sun Aug 24 14:52:53 1986
Date-Received: Sun, 24-Aug-86 19:48:37 EDT
Sender: daemon@ucbvax.BERKELEY.EDU
Organization: The ARPA Internet
Lines: 20