Computer Science Stack Exchange is a question and answer site for students, researchers and practitioners of computer science. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have been posed with a question whereby a computer truncates numbers to x number of digits. Due to this, if this computer is trying to store a decimal number which has a binary equivalent greater than x, it truncates the remaining digits producing a different binary number. However, this binary number is still an 'approximation' of what it should be, but of course is the equivalent of a different decimal number (close to what we were trying to store initially).

What problems can occur due to this incorrect storage of data?

share|cite|improve this question
You may be interested to read – Mok-Kong Shen Jan 26 '13 at 21:22

This is specifically about real numbers — integers can be represented exactly. Actually, real numbers can be represented exactly too, at least the one that matter, but this is very inefficient, so for most applications real numbers are represented by a floating point approximation.

By the way, this isn't specific to decimal numbers (numbers that can be represented in base 10 with a finite number of digits after the decimal point). No matter what base you choose, you can only represent a tiny subset of the real numbers (you can't even represent all rationals).

When computing with approximations, it's important to keep in mind that each step of computation may make the approximation worse, so that after many steps it's not always obvious how precise the result is — in some cases, the result is meaningless because the magnitude of the uncertainty is larger than the result. Numerical algorithms need to be constructed carefully to minimize errors due to approximations.

There is a whole subfield of computer science devoted to floating point calculations. To start with, read the classic paper What Every Computer Scientist Should Know About Floating-Point Arithmetic by David Goldberg.

share|cite|improve this answer

The question of finding a binary fraction which can be transformed back to the same decimal fraction was analized at great length by Knuth in his "A Simple Program Whose Proof Isn't", see

  language =     {english},
  author =       {Knuth, Donald E.},
  title =        {A Simple Program Whose Proof Isn't},
  booktitle =    {Beauty is Our Business},
  editor =       {Gries, David},
  year =         {1990},
  isbn =         {0-387-97299-4},
  pages =        {233--242},
  numpages =     {10},
  url =          {},
  acmid =        {119899},
  publisher =    {Springer-Verlag New York, Inc.},
  address =      {New York, NY, USA},
share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.