Problem with Cosine Calculation [SOLVED]

  1. What browsers show this problem?
    Tested with Chrome.
  2. Please share an example project (if possible).
  3. Describes the steps to reproduce this issue.
    Calculate cosine values using the block "cos of ..."
  4. What does Snap! currently do?
    Calculate incorrect cosine values.
  5. What should Snap! do instead?
    Calculate correct cosine values.

The provided project runs a variable i from 0 to 2*pi in 0.1 increments. Each step the cosine of i is calculated using the block "cos of ..." and added to a list.

The values in the list should go from 1 to 0 to -1 to 0 to 1. However, they always return something around 0.999.

Yes, there is indeed an error. Even with 100 digits of pi, it says:

If you cannot see the tiny text, it reports 0.9984971498638638

It's not a bug!

  • Your first item is not 1 because you are changing "i" before the first calculation. So the first item is cos(0.1).
  • Second and most important. Snap! trigonometric functions work in degrees. So cos (π) is not -1


Thanks for the clarification, Joan. Indeed, if I supply values between 0 and 360 the cosine is calculated correctly.