www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/02/03/08:16:27

From: Paul Shirley <Paul AT foobar DOT co DOT uk DOT chocolat>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: fixed point math: NEED HELP QUICK!
Date: Sun, 2 Feb 1997 22:11:40 +0000
Organization: wot? me?
Lines: 34
Distribution: world
Message-ID: <DnCrCDAcER9yEwKy@foobar.co.uk>
References: <5clmjm$ee3 AT nr1 DOT toronto DOT istar DOT net> <WWX+eCAORA8yEwz6 AT foobar DOT co DOT uk>
<19970131 DOT 205344 DOT 8463 DOT 0 DOT chambersb AT juno DOT com>
Reply-To: Paul Shirley <junk AT defeating DOT email DOT address>
NNTP-Posting-Host: chocolat.foobar.co.uk
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

In article <19970131 DOT 205344 DOT 8463 DOT 0 DOT chambersb AT juno DOT com>, Benjamin D
Chambers <chambersb AT juno DOT com> writes
>
>On Thu, 30 Jan 1997 02:15:42 +0000 Paul Shirley
><Paul AT foobar DOT co DOT uk DOT chocolat> writes:
>>In article <199701290130 DOT UAA02417 AT delorie DOT com>, DJ Delorie
>><dj AT delorie DOT com> writes
>>>
>>>> function.  Anyway, here's my problem;  To my understanding the 
>>following
>>>> are 100% equal:
>>>> 
>>>> other_stuff = stuff / 256;
>>>> other_stuff = stuff << 8;
>>>
>>>The second multiplies.  Try ">> 8" instead.
>>>
>>
>>And if other_stuff is signed, >>8 and /256 aren't identical either.
>>(which might save you some debugging later ;)
>Actually they are.  If it's signed, then I've noticed gcc shifts in the
>sign bit (with sal instead of shl).
>
>..Chambers

However shifting a -ve number rounds in the wrong direction...

ie ((-1) >> 1) becomes -1
but (-1)/2 becomes 0.

This can lead to some hard to find bugs.

---
Paul Shirley: shuffle chocolat before foobar for my real email address

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019