Advertisement
Whoneedspacee

Floating Point Numbers

Mar 31st, 2022
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. Floating point numbers are comprised of
  2. A Sign bit (0 for positive, 1 for negative)
  3. Exponent bits
  4. Mantissa bits
  5. 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
  6.  
  7. The floats whole value is
  8. (-1)^sign * 2^exponent * mantissa
  9.  
  10. 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.
  11.  
  12. 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
  13.  
  14. 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.
  15.  
  16. 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.
  17.  
  18. 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