[gameprogrammer] Re: Fixed point math

On Sun, 2004-11-07 at 00:15, Gautam Narain wrote:
> Hi,
> 
> Yes I can get by with 14.16 format. As long as the higher bit is 16 I should 
> be able to get along with it. How exactly would I implement 1.15 ? Could you 
> give me an example of converting a number to 1.15. However I am not sure  if 
> I can get by with 1.15.

As should be clear 1.15 is used to implement fractions with an extra bit
so you can handle +-1 exactly. So, you need to first convert the number
to a fraction by dividing by the range. So, if the number range is -1000
to 1000 you would convert n to 1.15 by (n << 15) / 1000

                Bob Pendleton

> 
> Thanks.
> Gautam
> 
> 
> >On Wed, 2004-10-20 at 12:08, Gautam Narain wrote:
> >Hi,
> >
> >>Kevin, you are partly right and partly wrong. I am targetting Opengl ES 
> >>which needs fixed point support. However I am targetting the Khronos 
> >>contest and not the gamedev one and a linux application(game). Anyway I do 
> >>this for a hobby so I figured well - I will aim for the contest.
> >>
> >>I changed the following in the code
> >>long long e = FIXMUL(c, d);
> 
> >My guess is that it is doing a 32 bit multiply and then converting the
> >result to 64 bits. It would do that because c and d are 32 bit numbers.
> 
> >>
> >>This gives me zero as well. However when I do it with floating point 
> >>numbers, I get the values after the decimal(fraction) correctly but the 
> >>main number is zero. Any ideas why it could be truncating ? Lastly I don't 
> >>think OpenGL ES has 64 bit support(so long long may not be supported). So 
> >>I will probably be stuck with int's. But I need to use 15.16 fixed point 
> >>variables. Should I do everything in 7.8 bit and the convert to 15.16 bit 
> >>? Would this slow things down or make it equal to if I did it with just 
> >>floats ?
> 
> >Why must you use 15.16 numbers? BTW, if you multiply a 7.8 number by
> >another 7.8 number you get a 14.16 number. Can you get by with
> >converting everything to a fraction and using something like 1.15
> >numbers?
> 
>  >               Bob Pendleton
> 
> >
> >>Thanks
> >>
> >>Gautam
> 
> _________________________________________________________________
> Millions of active and validated profiles.  
> http://www.bharatmatrimony.com/cgi-bin/bmclicks1.cgi?74 Find your match on 
> BharatMatrimony.com
> 
> 
> 
> ---------------------
> To unsubscribe go to http://gameprogrammer.com/mailinglist.html
> 
-- 
+--------------------------------------+
+ Bob Pendleton: writer and programmer +
+ email: Bob@xxxxxxxxxxxxx             +
+ blog:  www.Stonewolf.net             +
+ web:   www.GameProgrammer.com        +
+--------------------------------------+



---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html


Other related posts: