Problem with arduino maths

Your calculator is using Degrees. sin() uses Radians. (As is explained in the reference page.)

  float answer = sin(140.0);
  Serial.println(answer);

Returns 0.98. My calculator, in Radians-mode, returns the same thing.

If I assume you mean "140 degrees" then converting to radian:

 float answer = sin(140.0*(3.14/180.0));
  Serial.println(answer);

Returns 0.64.

Also note that my integers are in float/decimal. "140.0" instead of "140".

1 Like