+ 2

# cos(PI/2)=? Math everyone

what the output of this code? double a = Math. cos(Math. PI/2); double b = 0.0; if (a == b) Â System. out. println("True" ) ; else Â System.out.println("False") ; //answer False

5 Answers

+ 9

There are many questions which are not in lesson , but are in quizzes , U can always use google to learn more new thingsâșđ
(though most of specific & confusing quizzes are declined)

+ 3

InvBoy you probably missed the Math.cos part.
I agree that the question, though somewhat basic, is not really related to Java. Was it part of the tutorial here? If yes, then which lesson was it?

+ 3

Okay, I don't really think it's a great challenge question, but it does teach us about the issues with floating point precision. If you think it's not suitable for challenges, go ahead and report it! The Sololearn team can review and decide if they should remove the question.

+ 2

3.14... /2 is 0? Is a easy question

+ 2

double a = Math . cos(Math. PI/2);
a = 6.1234342....
but if we use integet type and casted it will be correct..
int a = (int) Math. cos(Math. PI/2) ; now a = 0