Mail Archives: djgpp/1997/02/03/19:21:00
Dim Zegebart writes:
>I just try to use fix math in Allegro. And I'm supprasing why where are
>no macros or functions like this (may be I missed something ?) :
>
>#define GET_INT(fFix) (int)(((fFix)>>16)&0x0000ffff)
This is the same as the fixtoi() function.
>#define GET_FIX(fFix) (int)((fFix)&0x0000ffff)
>#define SET_FIX(fFix,nFix) fFix=((fFix)&0xffff0000)|((nFix)&0x0000ffff)
>#define SET_INT(fFix,nInt)
>fFix=((fFix)&0x0000ffff)|(((nInt)<<16)&0xffff0000)
I don't really see why these would be needed. Allegro has functions to
convert fixed point values to/from floats and ints - why do you need to
access the integer and fractional parts individually? It seems to me
that you must be doing something pretty strange to require that :-) And
it's easy enough to access the values directly if you really need to:
IMHO, one of the big benefits of fixed point numbers is the simplicity
of bit-twiddling operations...
/*
* Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/
* Ghoti: 'gh' as in 'enough', 'o' as in 'women', and 'ti' as in 'nation'.
*/
- Raw text -