title: Float/Double calculation error in Java
body: <p>We are having some problems with calculations (divisions) in Java. </p>
  
  <p>A sample program to show the problem:</p>
  
  <pre><code>public class NumberTest {
  
      public static void main(String[] args) {
          System.out.println("Double value: " + 27.8625d);
          System.out.println("Float value: " + 27.8625f);
          System.out.println("Double value: " + 1000.0d);
          System.out.println("Float value: " + 1000.0f);
          System.out.println("Double calculation: " + 27.8625d/1000.0d);
          System.out.println("Float calculation: " + 27.8625f/1000.0f);
      }
  
  }
  </code></pre>
  
  <p><strong>Output</strong>:  </p>
  
  <pre><code>Double value: 27.8625  
  Float value: 27.8625  
  Double value: 1000.0  
  Float value: 1000.0  
  Double calculation: 0.027862500000000002  
  Float calculation: 0.027862499
  </code></pre>
  
  <p>I would expect the result of the calculations to be <code>"0.0278625"</code>. Why is there a different result for both the float and double calculation?</p>
  
  <p>Regards,</p>
  
  <p>Tim</p>