title: Java - Misunderstand ceil and floor methods
body: <p>floor:</p>
  
  <blockquote>
    <p>Returns the largest (closest to positive infinity) double value that is less than or equal to the argument and is equal to a mathematical integer. ...</p>
  </blockquote>
  
  <p>ceil:</p>
  
  <blockquote>
    <p>Returns the smallest (closest to negative infinity) double value that is greater than or equal to the argument and is equal to a mathematical integer. ...</p>
  </blockquote>
  
  <p>Source: <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html" rel="nofollow noreferrer">Docs Oracle</a></p>
  
  <p>About <strong>floor</strong>: If I type <code>System.out.print(Math.floor(2.1));</code> returns <code>2.0</code> . Other example: <code>System.out.print(Math.floor(2.8));</code> returns <code>2.0</code> . I am going to argue this description with the example: if <code>floor(2.1)</code> was the largest (closest to positive infinity) as a result would be <code>3.0</code> not <code>2.0</code>, because <code>2.0</code> is closest to negative infinity I think. So if I change the description about floor:</p>
  
  <blockquote>
    <p>Returns the smallest (closest to negative infinity) double value that is less than or equal to the argument and is equal to a mathematical integer. ...</p>
  </blockquote>
  
  <p>It makes sense for me, I would understand that <code>floor(2.1)</code> returns <code>2.0</code></p>
  
  <p>When I read "closest to positive infinity" and "closest to negative infinity" I think in the number line:</p>
  
  <p><a href="https://i.stack.imgur.com/R4hUw.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/R4hUw.jpg" alt="The number line"></a></p>
  
  <p>Source: <a href="https://www.quora.com/What-is-negative-infinity" rel="nofollow noreferrer">Quora</a></p>
  
  <p>EDIT: What I am asking is: the description broke my mind. My logic says (about <strong>floor</strong> for example): First, Ok when I listen floor I think in the smallest not in the largest. Second, if I returns the largest, that is greater not less than to the argument. The same happens with <strong>ceil</strong></p>