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?
UPDATE
Turns out I'm the dumbest programmer on earth. In my project the whole code is of course much more complex than the example above. It's kind of an expression parser & evaluator and for the defined mathematical functions I use a switch-clause to decide which function to call - I forgot the break statement in the cases which caused the sqrt function to be executed with a negative parameter.
As I said - dumbest programmer on earth...
I accepted the topmost answer as it is the best imho. Sorry guys for wasting your time -.-