Fixed-Point Math Fun

Feb 05, 2006 06:37

Alright. I give. I've read all that I could on bit-shifting and Fixed-point math, and I just either ( Read more... )

Leave a comment

Comments 3

(The comment has been removed)

ceramicpig February 5 2006, 15:55:12 UTC
Of course, this could also be simplified to

a = x + ((y * 10) / 100); // factored out *100/10

Another alternative that could possibly result in some lost precision (but probably not a big deal in most cases):

a = x + ((y * 1)/ 10);
b = x + ((y * 3)/ 10);
c = x + ((y * 3)/ 20);

Basically, if you do the multiplication first, you're getting a larger number that you're then dividing, rather than a fraction which gets truncated to 0.

You'll have to try out different methods, I guess. If neither of these work and you actually want to work with fixed point math, then some better examples of that can be provided! The Crappy Gamez Xplosions that Ovk has been holding have made certain that I am a fixed-point ninja. Or, at least, a low-level spy.

Reply

rysen February 6 2006, 05:28:58 UTC
w00t. I think I got it working now. Thanks guys, it helped immensley!

Reply

rysen February 6 2006, 05:54:19 UTC
Oh and, for the curious, that's part of my my super-new-fancy-automated leveling-up-algorthm-thingy. (Tm). (Read Preceeding "Stat Whore" post as to reasons why. :P)

Reply


Leave a comment

Up