Mail Archives: djgpp/1997/05/14/09:07:54
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 -