www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/05/14/09:07:54

From: ao950 AT FreeNet DOT Carleton DOT CA (Paul Derbyshire)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Allegro fixed point variables
Date: 14 May 1997 11:08:19 GMT
Organization: The National Capital FreeNet
Lines: 25
Message-ID: <5lc6f3$5j8@freenet-news.carleton.ca>
References: <19970513 DOT 174418 DOT 12478 DOT 0 DOT bshadwick AT juno DOT com>
Reply-To: ao950 AT FreeNet DOT Carleton DOT CA (Paul Derbyshire)
NNTP-Posting-Host: freenet5.carleton.ca
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Ben N Shadwick (bshadwick AT juno DOT com) writes:
> I was just messing around some more with a little program I made to test
> out Allegro, and I noticed in Allegro.txt it says (pertaining to fixed
> point numbers & angles):
> 
> "Angles are represented in a binary format with 256 equal to a full
> circle, 
> 64 being a right angle and so on. This has the advantage that a simple 
> bitwise 'and' can be used to keep the angle within the range zero to a
> full 
> circle, eliminating all those tiresome 'if (angle >= 360)' checks."
> 
> Call me stupid, but how exactly would I implement a bitwise and to get it
> to do that (in such a way that it would be more practical than the above
> check)?

If it were a regular int, use x & 0xff. Since it is a fixed, with some
sort of bit shift already built in, it is probably more like x &
0xffffffffff. (Shawn?)
--
    .*.  Where feelings are concerned, answers are rarely simple [GeneDeWeese]
 -()  <  When I go to the theater, I always go straight to the "bag and mix"
    `*'  bulk candy section...because variety is the spice of life... [me]
Paul Derbyshire ao950 AT freenet DOT carleton DOT ca, http://chat.carleton.ca/~pderbysh

- Raw text -


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