# Atan function not working correctly?

**URL:** <https://discourse.processing.org/t/atan-function-not-working-correctly/13340>\
**Category:** Beginners\
**Created:** [August 12, 2019, 4:45pm UTC](https://discourse.processing.org/t/atan-function-not-working-correctly/13340 "2019-08-12T16:45:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![inzywinki](https://avatars.discourse-cdn.com/v4/letter/i/dfb087/32.png) [@inzywinki](https://discourse.processing.org/u/inzywinki)\
**Post date:** [August 12, 2019, 4:45pm UTC](https://discourse.processing.org/t/atan-function-not-working-correctly/13340/1 "2019-08-12T16:45:48Z")

</div>

i am trying the inverse tangent function in processing java,  
i am using the atan(float) function,  
when i use a paramater around 100 / 70 i am getting the wrong result,  
this is true for atan(100 / 75), atan(100 / 80) and so on…  
converted to degrees, it always returns 45 degrees, which it does not on the windows calculator.

am i doing something wrong or is this not the function i am looking for when needing an inverse tangent?  
thanks in advance

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [August 12, 2019, 4:54pm UTC](https://discourse.processing.org/t/atan-function-not-working-correctly/13340/2 "2019-08-12T16:54:16Z")

</div>

> [@inzywinki](#):
>
> This is true for `atan(100 / 75)`, `atan(100 / 80)` and so on…

Try out `atan(100 / 75.0)` & `atan(100.0 / 80)` instead, so it’s not integer division anymore! 💡

---

<div class="post-metadata">

**Author:** ![inzywinki](https://avatars.discourse-cdn.com/v4/letter/i/dfb087/32.png) [@inzywinki](https://discourse.processing.org/u/inzywinki)\
**Post date:** [August 12, 2019, 5:26pm UTC](https://discourse.processing.org/t/atan-function-not-working-correctly/13340/3 "2019-08-12T17:26:41Z")

</div>

Thank you very much for this, rookie mistake!

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [August 12, 2019, 11:39pm UTC](https://discourse.processing.org/t/atan-function-not-working-correctly/13340/4 "2019-08-12T23:39:41Z")

</div>

I still make that mistake every so often but catch them. 🙂

There is also an atan2()

atan()  
[https://processing.org/reference/atan\_.html](https://processing.org/reference/atan_.html)

> **[Inverse trigonometric functions](https://en.wikipedia.org/wiki/Inverse_trigonometric_functions)**
>
> In mathematics, the inverse trigonometric functions (occasionally also called arcus functions, antitrigonometric functions or cyclometric functions) are the inverse functions of the trigonometric functions (with suitably restricted domains). Specifically, they are the inverses of the sine, cosine, tangent, cotangent, secant, and cosecant functions, and are used to obtain an angle from any of the angle's trigonometric ratios. Inverse trigonometric functions are widely us There are several notation...

atan2()  
[https://processing.org/reference/atan2\_.html](https://processing.org/reference/atan2_.html)  
[https://processing.org/examples/arctangent.html](https://processing.org/examples/arctangent.html)

> **[atan2](https://en.wikipedia.org/wiki/Atan2)**
>
> The function 
>   
>     
>       
> atan2
> ⁡
> (
> y
> ,
> x
> )
>       
>     
> {\\displaystyle \\operatorname {atan2} (y,x)}
>   
> or 
>   
>     
>       
> arctan2
> ⁡
> (
> y
> ,
> x
> )
>       
>     
> {\\displaystyle \\operatorname {arctan2} (y,x)}
>   
> (from "2-argument arctangent") is defined as the angle in the Euclidean plane, given in radians, between the positive x-axis and the ray to the point (x,y) ≠ (0,0). 
> The ...

Try this:

```auto
println(atan2(100, 75)); //You are still passing a float. See references.
println(atan(100.0/75));

```
