Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Work in Progress / Coming Soon : Fixed Points maths

Author
Message
OSX Using Happy Dude
20
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 12th Dec 2003 22:16
Modified slightly from the code by Andrew E. Mileski, it allows fixed point values (4 byte integers) to be used instead of floating-point values.


Did you bring the cloak of invisibility ? Oh damn, I left it in the bag of forgetfulness...
D Man
21
Years of Service
User Offline
Joined: 3rd Oct 2002
Location: Germany
Posted: 12th Dec 2003 22:20
Isn't that the same as Double Integers?

God is real, unless declared integer.
OSX Using Happy Dude
20
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 12th Dec 2003 23:54
yes.

Add, multiple (by power of w), subtract, divide (by power of 2) works and are pretty accurate.
Sin, cos, tan, exp are not accurate, and should only be regarded as (very) approximate.


Did you bring the cloak of invisibility ? Oh damn, I left it in the bag of forgetfulness...
D Man
21
Years of Service
User Offline
Joined: 3rd Oct 2002
Location: Germany
Posted: 13th Dec 2003 00:33
Ah..ok, thanks .

God is real, unless declared integer.
empty
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 13th Dec 2003 00:39 Edited at: 13th Dec 2003 00:40
Quote: "it allows fixed point values (4 byte integers) to be used instead of floating-point values."

4 byte integers?

Me, I'll sit and write this love song as I all too seldom do
build a little fire this midnight. It's good to be back home with you.
OSX Using Happy Dude
20
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 13th Dec 2003 00:43
LONGLONG's aka __int64


Did you bring the cloak of invisibility ? Oh damn, I left it in the bag of forgetfulness...
empty
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 13th Dec 2003 00:44
And how many bytes does it take to get 64 bits?

Me, I'll sit and write this love song as I all too seldom do
build a little fire this midnight. It's good to be back home with you.
OSX Using Happy Dude
20
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 13th Dec 2003 00:58
8 bytes.

Simply put, this library is limited to handling numbers with a whole
part of up to 2^31 - 1 = 2.147483647e9 in magnitude, and fractional
parts down to 2^-32 = 2.3283064365e-10 in magnitude. This yields a
decent range and accuracy for many applications.


Did you bring the cloak of invisibility ? Oh damn, I left it in the bag of forgetfulness...
empty
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 13th Dec 2003 01:02 Edited at: 13th Dec 2003 01:05
Yeah I know the Mileski library (although I'm not sure how it'll gain speed on today's x86 CPUs). Anyway the library uses 8 byte integers.

Me, I'll sit and write this love song as I all too seldom do
build a little fire this midnight. It's good to be back home with you.
OSX Using Happy Dude
20
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 13th Dec 2003 01:19
Its a shame SIN, COS, TAN etc are so very, very inaccurate (producing some daft figures at times) - I'll be posting the code in the code snippets section later, so if you want to have a peek and see if there is anything wrong, I'll be happy.


Did you bring the cloak of invisibility ? Oh damn, I left it in the bag of forgetfulness...
empty
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 13th Dec 2003 01:44
I'm pretty sure I have a C-like pseudo code covering fixed point maths for a Motorola DSP, but I can't find it.


There's a Java library for cell phones http://www.ai.mit.edu/people/hqm/imode/fplib/. It seems to use a slightly different approach (and works with 4 byte integers ). But I can't tell you how fast and/or precise it is.

Me, I'll sit and write this love song as I all too seldom do
build a little fire this midnight. It's good to be back home with you.
OSX Using Happy Dude
20
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 13th Dec 2003 01:46
Dont use Java anyway


Did you bring the cloak of invisibility ? Oh damn, I left it in the bag of forgetfulness...
empty
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 13th Dec 2003 01:47
But you could port it.

Me, I'll sit and write this love song as I all too seldom do
build a little fire this midnight. It's good to be back home with you.
OSX Using Happy Dude
20
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 13th Dec 2003 01:51
If I could read Java, maybe...


Did you bring the cloak of invisibility ? Oh damn, I left it in the bag of forgetfulness...

Login to post a reply

Server time is: 2024-04-20 04:13:50
Your offset time is: 2024-04-20 04:13:50