JS Built-ins
← Math98 / 215
Mathcosintermediate

Math.cos(Math.PI/2) β‰ˆ 0

πŸ“– Usage Example
// Cosine of an angle in radians
Math.cos(0)          // β†’ 1
Math.cos(Math.PI)    // β†’ -1

Use Math.cos() to compute the cosine of an angle (in radians) for trigonometry and graphics.

Math.cos(x)

Math.cos(Math.PI / 2) is not exactly 0 due to floating-point imprecision, but it is extremely close.

Challenge: Verify that Math.cos(Math.PI / 2) is approximately 0.

πŸ’‘ Hints (2)
  • β€’ cos(90Β°) = 0, but JavaScript uses floating-point which introduces tiny errors
  • β€’ Use tolerance checks instead of exact equality for trigonometric results