title: Can 12.1 be represented exactly as a floating point number?
body: <p>This is in reference to the comments in <a href="https://stackoverflow.com/questions/202302/rounding-to-an-arbitrary-number-of-significant-digits/202336#202336">this question</a>:</p>
  
  <blockquote>
    <p>This code in Java produces 12.100000000000001 and this is using 64-bit doubles which can present 12.1 exactly. – Pyrolistical </p>
  </blockquote>
  
  <p>Is this true? I felt that since a floating point number is represented as a sum of powers of two, you cannot represent 12.1 exactly, no matter how many bits you have. However, when I implemented both the algorithms and printed the results of calling them with (12.1, 3) with many significant digits, I get, for his and mine respectively:</p>
  
  <p>12.10000000000000000000000000000000000000000000000000000000000000000000000000
  12.10000000000000100000000000000000000000000000000000000000000000000000000000</p>
  
  <p>I printed this using <code>String.format("%76f")</code>. I know that's more zeros than necessary, but I don't see any rounding in the 12.1 .</p>