Javas Math.sin() produces NaN all the time
- by milan1612
Forgive me if this is a dumb beginners problem, but I really don't get it.
I have a member variable declared like so:
public Double Value;
When I assign 3.14159265 to Value and try to compute the sine of it, this happens:
system.out.println(Value.toString()); //outputs 3.14159265
Value = Math.sin(Value);
system.out.println(Value.toString()); //outputs NaN
In fact, this happens with every single value I tried - even with 0!
Math.sin() seems to always produce NaN as a result, regardless of the arguments value.
The docs say:
If the argument is NaN or an infinity, then the result is NaN.
But my argument is clearly not NaN or infinity!
What the heck is happening there?