🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.micro.atari16
Article #1614

Re: Division problem with Lattice C

#1614
From: Gert Poletiek
Date: Tue, 26 Aug 1986 07:37
41 lines
1608 bytes
In article <860824-115320-1121@Xerox> Opstad.osbunorth@Xerox.COM writes:
>
>  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)



How about it ?

This bug was mentioned on the distribution leaflet as a KNOW BUG in Lattice
3.03.04.

If memory serves me right all factor of two divisions are converted to a 
shift, but the shift count is one too small; ie. /2 becomes >>0 and /4
becomes >>1

Nice Uh ?


Gert Poletiek
Dutch Nation Institute for High Energy Physics
Amsterdam
The Netherlands
Technical Details
Message-ID: <199@nikhefh.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!mcvax!nikhefh!gert
References: <860824-115320-1121@Xerox>

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!mcvax!nikhefh!gert
From: gert@nikhefh.uucp (Gert Poletiek)
Newsgroups: net.micro.atari16
Subject: Re: Division problem with Lattice C
Message-ID: <199@nikhefh.UUCP>
Date: Tue, 26-Aug-86 03:37:06 EDT
Article-I.D.: nikhefh.199
Posted: Tue Aug 26 03:37:06 1986
Date-Received: Wed, 27-Aug-86 10:13:04 EDT
References: <860824-115320-1121@Xerox>
Reply-To: gert@nikhefh.uucp (Gert Poletiek)
Organization: NIKHEF-H  Amsterdam (the Netherlands)
Lines: 40
Apparently-To: rnews@mcvax