About This eBook by Bart De Smet

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

O'Reilly logo

Floating-Point Types

You might remember the different types of numbers from grade school. Natural numbers correspond to unsigned integral values, but where are the real numbers (not to mention fractional numbers)? In the world of computer science, the answer is twofold, with a significant difference with regard to precision. As humans, we’ve embraced the decimal system, likely directly related to the number of fingers we’re born with. Computers work with binary representation, though. This poses a problem with real numbers, some of which can’t be represented exactly in binary. Let’s give it a try:

0.30  <  1/2        = 0.50.30  >  1/4        = 0.250.30  <  1/4 + 1/8  = 0.3750.30  <  1/4 + 1/16 = 0.31250.30  >  1/4 + 1/32 = 0.28125

We can continue ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required