|
||
|
GP Mailing List
ATXGPSIG List
|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [gameprogrammer] Re: Fixed Point Library at gameprogrammer.com
Another thing I enjoy with using fixed point is that I'm learning a bit more about what types of numbers I should be using and should not be using. Like what happens when I multiply a really big number by a really small number? Fixed point helps me better visual my bounds. I only have 8 bits of fractions, so I can only have lines that are 256 "units" long, or else my math to determine the percentage along the line a collision occurred will start to be too far off. Also, I just personally like to have complete control over what my code is doing, and since I'm admittingly ignorant to exactly how floating point works and the dos and donts of using them, I fall back to "absolutely knowable" fixed point math. :-) I do need to learn the ins and outs of floating point eventually though. ;-) - Jeremiah On Dec 8, 2007 12:28 PM, Bob Pendleton <bob@pendleton.com> wrote: > > On Fri, 2007-12-07 at 17:04 -0800, Alan Wolfe wrote: > > I just finished writing some pretty intricate code using floating > > point and man, i hit so many problems...i was basically doing a "maze > > solving algorithm" on a bunch of intersecting line segments and so i > > was keeping track of where along a line the code was currently and > > looking for intersections beyond that position. > > > > Because of precision problems, it would sometimes find the same > > segment as the "next intersection" as it just came down and a couple > > other wierd problems. > > > > I tried playing with adding epsilons to the floats to counter act the > > precision issues which made other issues (really close intersections > > wouldnt get picked up). > > > > Eventually i had to do more heuristic logic instead of straight up > > mathematical decisions because no matter what i did mathematically i > > couldn't get it to work right. > > > > I've worked a little bit with fixed point, but IMO it seems like it > > really wouldnt solve the precision problems would it? > > > > What benefits besides speed do you get from using fixed point vs > > floating point? (: > > On modern CPUs with floating point hardware floating point is *much* > faster than integer arithmetic. On machines without floating point fixed > point is faster than using a software implementation of floating point. > > So, for most cases speed is the only reason to use fixed point and then > only on machines without floating point hardware. > > OTOH, and it is a big other hand, sometimes you need more precision than > you can get with hardware floating point. Think about it, single > precision floating point gives you 25 bits of precision (before you say > no to the 25 bits check out the way IEEE floating point handles the high > order bit of the factional part of a float). A 32 bit fixed point has 31 > bits, or 32 if you go unsigned, of precision. You have to go to double > precision to get better in floating point. Also, on 64 bit machines > pixed point gives you 63 bits of signed precision in fixed point. > > Of course I am leaving out a lot of details here. But fixed point can > give you a lot better precision in the same number of bits as a float. > It can also give you much better control (and awareness) of precision > problems than you get with floating point. It can also force you to > write assembly code and do some other odd things to make it work. > > Personally, I am very glad that I can just use double precision on a PC > and not have to worry about fixed point. But, I have done a *lot* of > fixed point programming. It takes a while to understand it, but learning > it will help you get the arithmetic right in your code for the rest of > your life. Of course, taking a good numerical analysis class can have > the same effect and not hurt nearly as much. > > Bob Pendleton > > --------------------- To unsubscribe go to http://gameprogrammer.com/mailinglist.html
|
|