Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: SirCmpwn on September 17, 2010, 08:47:21 pm

Title: Math
Post 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.
Title: Re: Math
Post by: calcdude84se on September 17, 2010, 08:55:00 pm
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.
Title: Re: Math
Post by: Deep Toaster on September 17, 2010, 09:03:34 pm
Here: http://ourl.ca/6413/103641 (http://ourl.ca/6413/103641)
Title: Re: Math
Post by: SirCmpwn on September 17, 2010, 10:38:43 pm
Ah, got it.  Thanks!
If anyone can shed light on division, I would appreciate it.  3D projection, anyone? ;)
Title: Re: Math
Post by: DJ Omnimaga on September 17, 2010, 10:56:13 pm
Mhmm... planning a new project? ;D
Title: Re: Math
Post by: Deep Toaster on September 17, 2010, 11:43:47 pm
/me wonders what this could be...

And about division, what about multiplying by a reciprocal? It might work sometimes.
Title: Re: Math
Post by: _player1537 on September 18, 2010, 01:43:15 am
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 :)
Title: Re: Math
Post by: Quigibo on September 18, 2010, 01:59:34 am
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.
Title: Re: Math
Post by: DJ Omnimaga on September 18, 2010, 02:07:59 am
Oh wow I remember that project. It was great. I hope you can convert it to Axe
Title: Re: Math
Post by: SirCmpwn on September 18, 2010, 09:09:38 am
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?
Title: Re: Math
Post by: calc84maniac on September 18, 2010, 11:15:12 am
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.
Title: Re: Math
Post by: SirCmpwn on September 18, 2010, 01:30:31 pm
So, I could say sin(42)*2->A and A would contain the fixed point value of the sine of 42?
Title: Re: Math
Post by: calc84maniac on September 18, 2010, 01:53:11 pm
So, I could say sin(42)*2->A and A would contain the fixed point value of the sine of 42?
That is correct.
Title: Re: Math
Post by: Quigibo on September 18, 2010, 04:01:02 pm
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.
Title: Re: Math
Post by: SirCmpwn on September 18, 2010, 06:07:49 pm
Okay.  Fixed point for perspective 3D is pretty important.
Title: Re: Math
Post by: Quigibo on September 18, 2010, 07:28:38 pm
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.
Title: Re: Math
Post by: SirCmpwn on September 18, 2010, 07:31:45 pm
Ah, I understand what you're saying now.  Thanks!