Javas Math.sin() produces NaN all the time

Posted by milan1612 on Stack Overflow See other posts from Stack Overflow or by milan1612
Published on 2010-03-18T15:22:31Z Indexed on 2010/03/18 15:31 UTC
Read the original article Hit count: 452

Filed under:
|
|
|

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?

© Stack Overflow or respective owner

Related posts about java

Related posts about math