I am building a calculator and I need to use cosinus. It works fine if I try cos(0), cos(30), but I get an odd output for cos(90) - 6.12323399573677e-17.
I checked the output for my radiansToDegrees and it looks ok.
Sinus works fine, for all the codes.
The numbers are in degrees not radians.
I use the latest xCode.
My code:
import Foundation
...
func radiansToDegrees (radians: Double)->Double {
return radians * 180 / M_PI
}
...
let number = degreesToRadians(Double(digitsLabel.text!)!)
digitsLabel.text = "\(cos(number))"
Does anyone have an idea what is wrong?