Skip to main content
Reverted some of my change. Misunderstood the range.
Source Link

For a 32-bit "single-precision" floating point number, we have 24 (23 stored + 1 implicit) of these mantissa bits to work with. That means in the range \$[2^n, 2^{n+1})\$ we have \$2^{24}\$\$2^{23}\$ representable numbers, spaced \$2^{n-24}\$\$2^{n-23}\$ apart.

If we try to store a number that falls between two representable numbers, it gets rounded to the nearest one, making an error of up to \$2^{n-25}\$\$2^{n-24}\$. That could, for example, nudge an object or vertex or camera position a little to the left or to the right of where it's supposed to be. This answer includes a table of what relative precision we have at various ranges from the origin.

For a 32-bit "single-precision" floating point number, we have 24 (23 stored + 1 implicit) of these mantissa bits to work with. That means in the range \$[2^n, 2^{n+1})\$ we have \$2^{24}\$ representable numbers, spaced \$2^{n-24}\$ apart.

If we try to store a number that falls between two representable numbers, it gets rounded to the nearest one, making an error of up to \$2^{n-25}\$. That could, for example, nudge an object or vertex or camera position a little to the left or to the right of where it's supposed to be. This answer includes a table of what relative precision we have at various ranges from the origin.

For a 32-bit "single-precision" floating point number, we have 24 (23 stored + 1 implicit) of these mantissa bits to work with. That means in the range \$[2^n, 2^{n+1})\$ we have \$2^{23}\$ representable numbers, spaced \$2^{n-23}\$ apart.

If we try to store a number that falls between two representable numbers, it gets rounded to the nearest one, making an error of up to \$2^{n-24}\$. That could, for example, nudge an object or vertex or camera position a little to the left or to the right of where it's supposed to be. This answer includes a table of what relative precision we have at various ranges from the origin.

Increased by 1 the precision due to the implicit bit in the mantissa
Source Link

For a 32-bit "single-precision" floating point number, we have 2324 (23 stored + 1 implicit) of these mantissa bits to work with. That means in the range \$[2^n, 2^{n+1})\$ we have \$2^{23}\$\$2^{24}\$ representable numbers, spaced \$2^{n-23}\$\$2^{n-24}\$ apart.

If we try to store a number that falls between two representable numbers, it gets rounded to the nearest one, making an error of up to \$2^{n-24}\$\$2^{n-25}\$. That could, for example, nudge an object or vertex or camera position a little to the left or to the right of where it's supposed to be. This answer includes a table of what relative precision we have at various ranges from the origin.

For a 32-bit "single-precision" floating point number, we have 23 of these mantissa bits to work with. That means in the range \$[2^n, 2^{n+1})\$ we have \$2^{23}\$ representable numbers, spaced \$2^{n-23}\$ apart.

If we try to store a number that falls between two representable numbers, it gets rounded to the nearest one, making an error of up to \$2^{n-24}\$. That could, for example, nudge an object or vertex or camera position a little to the left or to the right of where it's supposed to be. This answer includes a table of what relative precision we have at various ranges from the origin.

For a 32-bit "single-precision" floating point number, we have 24 (23 stored + 1 implicit) of these mantissa bits to work with. That means in the range \$[2^n, 2^{n+1})\$ we have \$2^{24}\$ representable numbers, spaced \$2^{n-24}\$ apart.

If we try to store a number that falls between two representable numbers, it gets rounded to the nearest one, making an error of up to \$2^{n-25}\$. That could, for example, nudge an object or vertex or camera position a little to the left or to the right of where it's supposed to be. This answer includes a table of what relative precision we have at various ranges from the origin.

Adding link to high-res version
Source Link
DMGregory
  • 136.3k
  • 22
  • 247
  • 373

Once we lose that precision in a calculation, we don't get it back if we later bring the result back closer to the origin - there are no bits left to encode that lost high-precision information, so it's not visible to any calculations downstream. This precision loss can snowball through repeated calculations, if we round a number, then use the rounded result to make a new number that also getgets rounded...

Animated example of loss of float precision See a high-res version of this visualization rendered in WebGL here

Once we lose that precision in a calculation, we don't get it back if we later bring the result back closer to the origin - there are no bits left to encode that lost high-precision information, so it's not visible to any calculations downstream. This precision loss can snowball through repeated calculations, if we round a number, then use the rounded result to make a new number that also get rounded...

Animated example of loss of float precision

Once we lose that precision in a calculation, we don't get it back if we later bring the result back closer to the origin - there are no bits left to encode that lost high-precision information, so it's not visible to any calculations downstream. This precision loss can snowball through repeated calculations, if we round a number, then use the rounded result to make a new number that also gets rounded...

Animated example of loss of float precision See a high-res version of this visualization rendered in WebGL here

Adding animated example
Source Link
DMGregory
  • 136.3k
  • 22
  • 247
  • 373
Loading
Source Link
DMGregory
  • 136.3k
  • 22
  • 247
  • 373
Loading