Math.atan(double a) is not accurate.

EDIT!!!!

Silly me, I forgot that 5's and 10's were int. PLEASE DISREGARD for I FOUND OUT!

double in = 5/5;

double degrees = Math.toDegrees(Math.atan(in));

double in = 10/5;

double degrees = Math.toDegrees(Math.atan(in));

All numbers for "in" between 1 and 2 generated the exact same 45 degrees.

Without the Math.toDegrees(), it still generates .7xxxxxx (radian version :P);

My question is, why? I really don't see anything wrong, but this is the first time I use atan (normally I'd use sines and cosines);

halp.

Re: Math.atan(double a) is not accurate.

Run this program to see what is wrong:

Code:

`public class Foo {`

public static void main(String[] args) {

double in = 5/5;

System.out.println("in: " + in);

in = 10 / 5;

System.out.println("in: " + in);

// so far so good, right?

in = 3 / 5;

System.out.println("in: " + in);

// now the output is not so good.

// what about...

in = 3.0 / 5;

System.out.println("in: " + in);

// ah, that's better!

}

}

Then Google Java int division to see why you're seeing the results above.