[OT] Fixed Point Math ( was Re: semicircle )

Search this archive.

From: Clive Crous (ccrous@shoprite.co.za)
Date: Wed 01 Dec 1999 - 10:49:00 IST


ok, last night i went and attempted to get that semicircle algorith of mine
working.
i discovered 3 problems.
    1>    i need to research type casting ;-)
    2>    it'll draw a semi circle with the "curve" being 1280 degrees or
LESS
    3>    Fixed point math doesn't work in c ??????????????

I used to do a lot of graphical type programming using pascal/assembler and
everything i did was *speed* orientated.  For this reason I got quite used
to using fixed point math in my calculations instead of relying on the FPU
to do the grunt work.

here's a quick lil snippet of my program, and the results it gave ..
----------------------------------------------------------------
#define FIXED_B 16
#define FIXED_M 1<<FIXED_B
<snip>
int xp,cx;
<snip>
cx=xp/FIXED_M;
fprintf(stdout," %d = %d / %d\n",cx,xp,FIXED_M);
<snip>
----------------------------------------------------------------
output gives:

2808465 = 2808465 / 65536
or
-2808465 = 2808465 / 65536
or
-65536 = 2808465 / 65536

?????????? wtf ?

cx always seems to be ((xp)||(-xp)||(FIXED_M)||(-FIXED_M))
----------------------------------------------------------------

could some1 please tell me what i've done wrong ?

thanks in advance
    Clive


This archive was generated by hypermail 2.1.4 : Wed 21 Jan 2004 - 22:10:22 IST