I am getting a wrong value when I do this
NSLog(@"cos 90 is %.f", cos(90.0));
The answer I get is -0. When I did a Google search, this is what I got:
cos(90 radians) = -0.448073616.
However the answer that my Casio calculator gives me is 0, and also when I was growing up as a kid, cos 90 = 0 was drilled into my brain.
Who is right, is it ObjC, Google, or my Casio calculator?
It all depends on whether you’re measuring in degrees or radians.
90 degrees (pi/2 radians) has, as you said, a cosine of 0. That’s pretty much by definition.
90 radians is 14.323945 times around a circle. The only part that matters is the remainder: 0.323945 of a circle, or 2.035406 radians. The cosine of that is (as you already found) -0.448074. This one isn’t a definition, so the real numbers are irrational, and what I’ve quoted are only approximations.