title: Guarantees concerning Math.atan2
body: <p>The documentation for <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#atan2-double-double-">Math.atan2</a> says</p>
  
  <blockquote>
    <p>The computed result must be within 2 ulps of the exact result.</p>
  </blockquote>
  
  <p>The fact that it says 2 ulps presumably means there are cases where the returned value is not the closest <code>double</code> to the true result. Does anyone know if it is guaranteed to return the same value for equivalent pairs of <code>int</code> parameters? In other words, if <code>a</code>, <code>b</code> and <code>k</code> are positive <code>int</code> values and neither <code>a * k</code> nor <code>b * k</code> overflows, is it guaranteed that</p>
  
  <pre><code>Math.atan2(a, b) == Math.atan2(a * k, b * k) 
  </code></pre>
  
  <p><strong>Edit</strong></p>
  
  <p>Note that this is definitely not the case for non-overflowing <code>long</code> multiplications. For example</p>
  
  <pre><code>long a = 959786689;
  long b = 363236985;
  long k = 9675271;
  System.out.println(Math.atan2(a, b));
  System.out.println(Math.atan2(a * k, b * k));
  </code></pre>
  
  <p>prints</p>
  
  <pre><code>1.2089992287797169
  1.208999228779717
  </code></pre>
  
  <p>but I could not find an example in <code>int</code> values.</p>