-2

I have a code to calculate the cos number.

But the answer is obtained in RAD.

How can I make it so that the response is displayed in DEG?

currentInput = cos(currentInput)

var currentInput: Double

Example:

cos 45 = 0.52532198881 (RAD)

cos 45 = 0.70710678118 (DEG)

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
B2Fq
  • 876
  • 1
  • 8
  • 23
  • 1
    180 degrees = Pi radians. That is all you need to know. You should be able to use that to convert between radians and degrees. Having said that, you are misunderstanding what cos does here. The result is not in degrees or radians. The result is a dimensionless number. In your example it is the number 45 that is radians in the first line and degrees in the second line. M – Fogmeister Nov 18 '17 at 11:26

1 Answers1

2

sure

cos(45 * Double.pi / 180)
Quver
  • 1,408
  • 14
  • 21