Omnimaga
Calculator Community => TI Calculators => Axe => Topic started by: SirCmpwn on September 17, 2010, 08:47:21 pm
-
Hello,
How do you do fixed point math in Axe? For instance, 2.5 * 2.
-
E0280**E0200 computes your example and returns E0500
In short, it treats the hex number AABB like AA.BB (note the hexadecimal point)
You have to use ** instead of *, but you can still use + and - (and >>, <<, >=>=, and <=<=)
I'm not sure about division.
-
Here: http://ourl.ca/6413/103641 (http://ourl.ca/6413/103641)
-
Ah, got it. Thanks!
If anyone can shed light on division, I would appreciate it. 3D projection, anyone? ;)
-
Mhmm... planning a new project? ;D
-
/me wonders what this could be...
And about division, what about multiplying by a reciprocal? It might work sometimes.
-
Yay SIr! You're working on this now! Can't wait to play with it :D I hope you keep it easy to use with other programs. (all that assuming this is the program you showed me a long time ago :D)
Edit: http://ourl.ca/4772 :)
-
To find the reciprocal of a signed fixed point number "A", do this:
E8000//A*2*-1
Once you have the reciprocal, you can do a regular fixed point multiplication to do the actual "division". One bit of accuracy is lost though when using this method. I am thinking of having an inverse function built in for fixed point since I'm not using that token yet.
-
Oh wow I remember that project. It was great. I hope you can convert it to Axe
-
Yeah, I've been meaning to try ever since fixed point support.
Quigibo, I don't quite understand, how would I divide 5/2 with this example of yours?
Also, how would I convert the result of a sine or cosine to a fixed point number?
-
Yeah, I've been meaning to try ever since fixed point support.
Quigibo, I don't quite understand, how would I divide 5/2 with this example of yours?
Also, how would I convert the result of a sine or cosine to a fixed point number?
Actually, if you are multiplying or dividing by an integer, you can simplify (and sometimes optimize) by doing it normally. 5/2 would be e0500//2.
Sine and cosine return a value from -128 to 128 (representing -1 to 1). In 8.8 fixed point, -256 is -1 and 256 is 1. So, you would have to multiply the sin/cos value by 2.
-
So, I could say sin(42)*2->A and A would contain the fixed point value of the sine of 42?
-
So, I could say sin(42)*2->A and A would contain the fixed point value of the sine of 42?
That is correct.
-
By the way, if you're trying to model a 3D engine, you can check the source code of the CUBE.8xp example program. It takes a list of lines defined by 2 points and draws them all to the screen. In the cube's case, there were 12 lines representing the edges of the cube. I don't even think I used fixed point operations in that one since they aren't absolutely necessary, you'll have to see what optimizes better.
-
Okay. Fixed point for perspective 3D is pretty important.
-
I mean that you'll still be using fixed point numbers, but often you can get away with not needing fixed point operations. To multiply or divide your fixed point number by an integer for instance is not the ** operation but is actually the regular multiplication which is what calc84maniac was talking about. Sine and Cosine multiplication can also be done without the ** operation like I did in the cube example since you don't care about the decimal part of the number when drawing to the screen anyway so it doesn't matter that it gets clipped off.
-
Ah, I understand what you're saying now. Thanks!