cos(PI/2)=? Math everyone | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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

2nd Jan 2019, 3:40 AM
Azeddine Hamdaoui
Azeddine Hamdaoui - avatar
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)
2nd Jan 2019, 4:18 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 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?
2nd Jan 2019, 4:16 AM
Kishalaya Saha
Kishalaya Saha - avatar
+ 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.
2nd Jan 2019, 4:54 AM
Kishalaya Saha
Kishalaya Saha - avatar
+ 2
3.14... /2 is 0? Is a easy question
2nd Jan 2019, 4:00 AM
InvBoy [ :: FEDE :: ]
InvBoy [ :: FEDE :: ] - avatar
+ 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
2nd Jan 2019, 4:41 AM
Azeddine Hamdaoui
Azeddine Hamdaoui - avatar