i tried to better understand how float values are stored on a computer so i decided to write a little class that should help me with this.
IMPORTANT NOTE: i can’t be held responsible for anything that this class does or does not, you’ve been warned :p
list of know issues:
- the methods floatUnderstandingFromLongValue() and floatUnderstandingFromDoubleValue() return WRONG FLOATS!
- maybe the method getMantissaBitsSignificanceString() is also not working correctly, especially with really small numbers (E=-126)
- code has gotten a little confusing
- things could probably be coded more efficiently
you can download the source from here:
http://pascal-schwarz.ch/stuff/FloatUnderstanding/FloatUnderstanding.java
http://pascal-schwarz.ch/stuff/FloatUnderstanding/TestRecalcMultiThread.java
if you have any feedback, please use the comment-functionality under this post.
Update (20.03.2011):
- better handling of denormalized values (getMantissaValue(), getMantissaSignificanceString(), getExponentValue(), …..)
- included a multithreaded recalcFloatValue-Tester
- the fabric-methods floatUnderstandingFromLongValue() and floatUnderstandingFromDoubleValue() ARE NOT FIXED yet

Trackback URI | Comments RSS
Leave a Reply