title: Why does Math.ceil return a double?
body: <p>When I call <code>Math.ceil(5.2)</code> the return is the <code>double</code> <code>6.0</code>. My natural inclination was to think that <code>Math.ceil(double a)</code> would return a <code>long</code>. From the documentation:</p>
  
  <blockquote>
    <p><code>ceil(double a)</code></p>
    
    <p>Returns the smallest (closest to negative infinity) <code>double</code> value
    that is not less than the argument and is equal to a mathematical
    integer.</p>
  </blockquote>
  
  <p>But why return a <code>double</code> rather than a <code>long</code> when the result is an integer? I think understanding the reason behind it might help me understand Java a bit better. It also might help me figure out if I'll get myself into trouble by casting to a <code>long</code>, e.g. is</p>
  
  <p><code>long b = (long)Math.ceil(a);</code></p>
  
  <p>always what I think it should be? I fear there could be some boundary cases that are problematic.</p>