|
-
May 25th, 2004, 03:43 PM
#1
Thread Starter
Addicted Member
Optimizing single-precision floating-point variables
I am currently working on making a physics engine. It involves a lot of matrix math, so I am thinking about using D3DX (part of DirectX) for speed reasons. The problem with this is that DirectX uses singles for its vectors.
My question is how do I get the most out of the singles, I want all the accuracy I can get. The single is 32-bit, but it uses an exponent. I think its layout looks like this:
Code:
S EEEEEEEE FFFFFFFFFFFFFFFFFFFFFFF
0 1 8 9 31
S = Sign bit
E = Exponent bits
F = Fraction bits
Now using the sign bit and the fraction bits to their full extent gives me 24 bits that should allow for a range of 2^24 or 16,777,216. This doesn't seem like enough accuracy.
Now clearly the 8-bit exponent gives me a lot more room, but I don't know how to fully use it. If I were to use the full range of the exponent it would leave huge "gaps" in my numbers.
Anyway, how do I get the most out of this data type? Any advice would be helpful.
Thanks!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|