Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Floating point numbers are comprised of
- A Sign bit (0 for positive, 1 for negative)
- Exponent bits
- Mantissa bits
- For the mantissa a 1 is implied, and then the mantissa value is added on, so 1100 would be 1 + 1/2 + 1/2^2
- The floats whole value is
- (-1)^sign * 2^exponent * mantissa
- This means that the exponent basically bit shifts the mantissa. If you add 1 to the exponent bits then the precision for the mantissa becomes less.
- If your least significant bit represents 1/2^4 in 1 byte like 0001, then for your float value if you have an exponent of 4 then you would not be able to have decimals. The smallest value you can add would be 2^4 * 1/2^4 = 1
- Vice versa, if you fill up your entire mantissa up to 1111 and then add 1, your exponent increases by 1 because of overflow. This is how float counting works.
- This is why when you reach a high enough level of distance in games like minecraft that your character jitters around. Your characters position is a float value.
- At 2^23 blocks away from spawn, your exponent is so big that for even a 32 bit float you cannot have any decimal values and can only move like you're jumping points on a coordinate grid.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement