http://asawicki.info/ Programming, graphics, games, media, C++, Windows, Internet and more... 


22:53
Thu
13
Jun 2013
FloatingPoint Formats Cheatsheet
Floatingpoint numbers (or floats in short) are not as simple as integer numbers. There is much to be understood when dealing with these numbers on low level  basic things like the sign + exponent + significand representation (and that exponent is biased, while significand has implicit leading 1), why you should never compare calculation results operator ==, that some fractions with finite decimal representation cannot be represented exactly in binary etc., as well as why there are two zeros 0 and +1, what are infinite, NaN (Not a Number) and denorm (denormal numbers) and how they behave. I won't describe it here. It's not an arcane knowledge  you can find many information about this on the Web, starting from Wikipedia article.
But after you understand these concepts, quantitative questions come to mind, like: how many significant decimal digits can we expect from precision of particular float representation (half, single, double)? What is the minimum nonzero value representable in that format? What range of integers can we represent exactly? What is the maximum value? And finally: if our game crashes with "Access violation, reading location 0x3f800000", what chances are that we mistaken pointer for a float number, as this is one of common values, meaning 1.0?
So to organize such knowledge, I created a "FloatingPoint Formats" cheatsheet:
Floats_cheatsheet.pdf
Floats_cheatsheet.docx
Comments (0)  Tags: productions math  Author: Adam Sawicki  Share
[Stat] [Admin] [STAT NO AD] [pub] [Mirror]  Copyright © 20042017 Adam Sawicki 