Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / JavaScript

Math.sin: sine in radians

Math.sin converts its argument to Number and returns an approximation of its sine, interpreting the angle in radians.

Version: ECMAScript 1 onward; example target: Node.js 24.22.2

Syntax

Math.sin(x)

Math.sin(x) applies ToNumber and computes the sine of a finite angle in radians. The mathematical result lies from -1 through 1, while the represented value is an implementation-dependent binary64 approximation. Math.sin(+0) returns +0, and Math.sin(-0) returns -0.

NaN, Infinity, -Infinity, and a missing argument produce NaN. A numeric string is converted, while a Symbol or BigInt throws TypeError; an object can run conversion code. Even Math.sin(Math.PI) need not be exactly zero because π and the calculation are approximated.

The function has existed since ECMAScript 1 and is not a constructor. Convert degrees explicitly with degrees * Math.PI / 180; the example produces approximately 0.5 for 30°. In periodic algorithms, reduce extremely large angles carefully because Number precision loss can affect the result.

Examples

console.log([0, Math.PI / 2, Math.PI].map((x) => Math.sin(x).toFixed(6)).join(","));
console.log(Math.sin(30 * Math.PI / 180).toFixed(6));
console.log(Object.is(Math.sin(-0), -0));
console.log(Number.isNaN(Math.sin(Infinity)), Number.isNaN(Math.sin()));
try { Math.sin(1n); } catch (error) { console.log(error instanceof TypeError); }

Result

0.000000,1.000000,0.000000
0.500000
true
true true
true

Math.sin → radians, 30° conversion, and preserved -0

Sources