TrevorBradley
Active Member
- Joined
- Nov 6, 2007
- Messages
- 732
EDIT: Read down, I disprove that this is useful further down the page, but thought I'd share this anyways.
I know that integer math is pretty fast on Pandora, and floating point math is fairly slow on the pandora, and I know that NEON there to help get around the problem.
I'm trying to wrap my head around why this might be an issue. Float and int are both 32-bit. The only thing that makes logical sense is that float have floating decimal places, and that mathematics like exp(10,10)*exp(10,-10) are significantly more complicated than 2+2.
After some hard thought, it might be possible to convert my game from float to int. It would take a bit of work, but the mathematics I'm doing with these floats is somewhere between 0.1 to 200000. Perhaps 0.001 to 200000 to be safe if I'm thinking of radians. Which scaled up by 1000 works out to 1 to 2*10^8, within integer's range.
Now, rather than going to convert everything throughout the program, the thought occurred that I might be able to create a new data class (let's call it "flint") and overload the math operators. Data would be stored as an int, but really be a float, like so:
CODE
flint | float value
0 | 0
1 | 0.001
1000 | 1.0
-1000 | -1.0
100000000 | 100000.0
123456789 | 123456.789
Overloading +, - and == would be a snap. * and / slightly harder, but doable. Things get much harder with sin, cos, atan and log (each of which I need) but might be within my grasp.
... pauses ...
Y'know... I was hoping typing this up after thinking about it would bring some clarity, and I'm afraid it has. Multiplication is going to be pretty expensive. I was going to ask if I was attempting to reinvent the wheel and I believe I was about to.
123456.0 * 2.222 is a non trivial calculation for the floating point core. For integer math and my proposed flints, there would be overflow issues for almost every calculation.
I could nuke this but I've typed it up and might as well share the thought process, even if it is incorrect.
Back to thinking about NEON then..
I know that integer math is pretty fast on Pandora, and floating point math is fairly slow on the pandora, and I know that NEON there to help get around the problem.
I'm trying to wrap my head around why this might be an issue. Float and int are both 32-bit. The only thing that makes logical sense is that float have floating decimal places, and that mathematics like exp(10,10)*exp(10,-10) are significantly more complicated than 2+2.
After some hard thought, it might be possible to convert my game from float to int. It would take a bit of work, but the mathematics I'm doing with these floats is somewhere between 0.1 to 200000. Perhaps 0.001 to 200000 to be safe if I'm thinking of radians. Which scaled up by 1000 works out to 1 to 2*10^8, within integer's range.
Now, rather than going to convert everything throughout the program, the thought occurred that I might be able to create a new data class (let's call it "flint") and overload the math operators. Data would be stored as an int, but really be a float, like so:
CODE
flint | float value
0 | 0
1 | 0.001
1000 | 1.0
-1000 | -1.0
100000000 | 100000.0
123456789 | 123456.789
Overloading +, - and == would be a snap. * and / slightly harder, but doable. Things get much harder with sin, cos, atan and log (each of which I need) but might be within my grasp.
... pauses ...
Y'know... I was hoping typing this up after thinking about it would bring some clarity, and I'm afraid it has. Multiplication is going to be pretty expensive. I was going to ask if I was attempting to reinvent the wheel and I believe I was about to.
123456.0 * 2.222 is a non trivial calculation for the floating point core. For integer math and my proposed flints, there would be overflow issues for almost every calculation.
I could nuke this but I've typed it up and might as well share the thought process, even if it is incorrect.
Back to thinking about NEON then..