title: Rounding oddity - what is special about "100"?
body: <p>Does anyone have an explanation for this strange rounding in haskell (GHCi, version 7.2.1). Everything seems fine unless I multiply with 100.</p>
  
  <pre><code>*Main&gt; 1.1 
  1.1
  
  *Main&gt; 1.1 *10
  11.0
  
  *Main&gt; 1.1 *100
  110.00000000000001
  
  *Main&gt; 1.1 *1000
  1100.0
  
  *Main&gt; 1.1 *10000
  11000.0
  </code></pre>
  
  <p>Edit: what is puzzeling me is that the rounding error only shows when multiplying with 100.</p>
  
  <p>Edit(2): The comments I received made me realize, that this it totally unrelated to haskell, but a general issue with floating point numbers. Numerous questions were already asked (and answered) about floating-point number oddities, where the undelying issue typcally was confusing floats with real numbers.</p>
  
  <p>Perl, python, javascript and C all report <code>1.1 * 100.0 = 110.00000000000001</code>. Here is what C does</p>
  
  <pre><code>double     10.0 * 1.1 = 11.000000000000000000000000
  double    100.0 * 1.1 = 110.000000000000014210854715
  double          110.0 = 110.000000000000000000000000
  double   1000.0 * 1.1 = 1100.000000000000000000000000
  </code></pre>
  
  <p>The question "why does this happen only when multiplying with 100" (even though there is a precise representation for 110.0) is still unanswered, but I  suppose there is no simple answer, other than fully stepping through a floating-point multiplication (Thanks to Dax Fohl for stressing that 10 is nothing special in binary)</p>