From: abc AT abc DOT com (riotnrrd) Newsgroups: comp.os.msdos.djgpp Subject: Re: Definiton of fixed in Allegro Date: Fri, 16 Jan 1998 09:14:03 GMT Organization: Magna Data - Internet Solutions Provider Lines: 41 Message-ID: <34bf243e.9083522@news.magna.com.au> References: <34BD6A0D DOT E82119F5 AT rogers DOT wave DOT ca> <250eqCAbmcv0EwUx AT talula DOT demon DOT co DOT uk> NNTP-Posting-Host: saccess-07-021.magna.com.au To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Can I cut in? I'm going to anyway...quick q about fixed type... Shawn : If I have a fixed type variable called fix_var or whatever, can I use -fix_var to get the negative value of it? On Thu, 15 Jan 1998 08:32:27 +0000, Shawn Hargreaves wrote: >Shaun Jackman writes: >>I searched the Allegro source but I couldn't find the definitions of the >>fixed point typedef and its support functions. > >Look in allegro.h and search for "math routines". > >>What this comes down to specifically, is I need support for a 28.4 fixed >>point structure, and I'm trying to figure out what the best way to do >>this is. > >In terms of declaring, adding, comparing, etc, you can use normal >integer types. The formula for a 28.4 multiply is (a*b)>>4, which you >can code directly in C or with a macro if you don't mind the chance of >overflow (Allegro uses inline asm to produce a 64 bit temp value, so it >cannot overflow before I shift it back down to the correct range, but >this is a much bigger issue with 16 fractional bits than if you are only >using four). Division is the other way round, (a<<4)/b, so the same temp >overflow problem can occur. > >>Also, I would like to know the overhead of the ftofix and fixtof >>functions. > >The fixtof() is just a divide by 65536.0. Converting ftofix() is >slightly more expensive because it does a range check, but nothing too >complicated. > > >-- >Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/ >"Pigs use it for a tambourine" - Frank Zappa