Could you use integers?

So using integers for the physics would be a good idea not only
for speed but for consistency?
I wonder though how you would handle sin() cos() since they
require floating point?
What about for non physics applications say a financial app?
Does that mean someones calculations would be different from another
depending on the computer it's run from?
How do banks work? lol
Mike
banks only have the program running on the server, not on the client, plus i'd imagine they use some pretty heavy numerical libraries! 🙂

i would assume that fixed-point apps that need trig functions/etc just approximate them using numerical methods or a lookup table; finding out how such functions are implemented for floatingpoint (on the CPU) would probably point you in a useful direction.
With the note that all of this is pretty far off-topic as relates to Box2d...

@mike950: Banks (should, at least) use arbitrary precision decimal math libraries, because both floating point and fixed point math have limitations - floating point has resolution problems when you get to very high numbers (I don't remember the exact point at which you can no longer increment a penny, but if I recall it's not an obscene amount of money as far as banks are concerned) as well as rounding issues even for normal numbers, and fixed point has issues because rounding causes missing cents here and there. I couldn't find a good link to explain how to do this stuff, but needless to say, it's not viable for a physics engine that needs to run in real time.

As far as sin, cos, sqrt, and all that, there are good fixed point routines that can handle these things. It's not fun to figure them out, and it's especially a pain to try to get them to run fast, but it is doable - if you search around, I'm sure you can find some explanations. For sqrt you can use a Newton-Raphson expansion to solve (sqrt x)^2 - x = 0, and it gives very good results in only a few iterations; for sin and cos I forget which trick works best, it might be a vanilla Taylor series, though I suspect that the best implementations use something from the immense bag of infinite series tricks to speed convergence. It all has to happen with fixed point math, so it looks ugly, but works fine.

@raigan: It's truly obnoxious of DirectX to change these settings as it feels like it, not to get started on a Microsoft rant or anything. Apparently you can turn this behavior off, luckily, though at some cost: http://forums.microsoft.com/MSDN/ShowPo ... 1&SiteID=1

Re: the intermediate precision issues, I think you're right about that, and it's not just when overflow is an issue that the results could differ, so perhaps strictfp is actually more important in Java than I had realized before. For any Java programmers out there, it's worth noting that the trig functions in Java tend to be particularly slow because Java requires more accuracy from these functions than most processors provide, especially for large values of the arguments, and a slow "fixing up" of the results is forced. Use tables if you really need the speed (we're going to do this in JBox2d soon, I think), or map all arguments to keep them less than pi/4 or so.
Thanks guys for all the great info!
I guess it does seem off on a tangent from Box2d but
I do have something in mind that all this could effect it.
I was thinking of porting my shockwave browser based game
to flash now that skatehead did such a great job porting it.
But since it's multiplayer I guess I can't rely on each client's simulation
being identical since one might be using linux and another windows
or mac.
Mike
Some people have already ported various versions of Box2D to platforms that don't have FPUs. For example the GP32.

http://en.wikipedia.org/wiki/GP32

So it is possible to run with fixed point, but I would never make the main line of Box2D run with fixed point. IMHO that would be a step back into the dark ages of programming.

Original thread: https://box2d.org/forum/viewtopic.php?t=175