Skip to content

StdLib Number Math

Roger Johansson edited this page Jan 14, 2026 · 1 revision

Number and Math

The Number and Math built-ins provide numeric operations and mathematical functions.

Implementation Status: 100% Complete

Number Overview

Category Items Implemented
Static Methods 6 6
Static Constants 8 8
Prototype Methods 6 6
Total 20 20

Number Static Methods

Method Status Description
Number.isInteger(value) Implemented Checks if finite integer
Number.isFinite(value) Implemented Type-strict finite check
Number.isNaN(value) Implemented Type-strict NaN check
Number.isSafeInteger(value) Implemented Within +/-2^53-1 range
Number.parseFloat(string) Implemented Parses floating-point
Number.parseInt(string, radix) Implemented Parses integer (radix 2-36)

Number Static Constants

Constant Value Description
Number.EPSILON 2^-52 Smallest difference between 1 and next float
Number.MAX_SAFE_INTEGER 2^53-1 9007199254740991
Number.MIN_SAFE_INTEGER -(2^53-1) -9007199254740991
Number.MAX_VALUE ~1.8e308 Largest positive finite value
Number.MIN_VALUE ~5e-324 Smallest positive value
Number.POSITIVE_INFINITY Infinity Positive infinity
Number.NEGATIVE_INFINITY -Infinity Negative infinity
Number.NaN NaN Not-a-Number

Number Prototype Methods

Method Status Description
toString(radix) Implemented Converts to string (radix 2-36)
valueOf() Implemented Returns primitive value
toFixed(digits) Implemented Fixed-point notation (0-100 digits)
toExponential(digits) Implemented Exponential notation (0-100 digits)
toPrecision(precision) Implemented Precision notation (1-100)
toLocaleString(locales, options) Implemented Intl.NumberFormat integration

Math Overview

Category Items Implemented
Methods 36 36
Constants 8 8
Total 44 44

Math Methods

Basic Operations

Method Status Description
Math.abs(x) Implemented Absolute value
Math.ceil(x) Implemented Round up
Math.floor(x) Implemented Round down
Math.round(x) Implemented Round to nearest (half-away-from-zero)
Math.trunc(x) Implemented Truncate toward zero
Math.sign(x) Implemented Sign of number (-1, 0, 1)
Math.max(...values) Implemented Maximum value
Math.min(...values) Implemented Minimum value

Power and Root

Method Status Description
Math.pow(base, exp) Implemented Exponentiation
Math.sqrt(x) Implemented Square root
Math.cbrt(x) Implemented Cube root
Math.hypot(...values) Implemented Euclidean distance

Exponential and Logarithmic

Method Status Description
Math.exp(x) Implemented e^x
Math.expm1(x) Implemented e^x - 1 (precise for small x)
Math.log(x) Implemented Natural logarithm
Math.log10(x) Implemented Base-10 logarithm
Math.log2(x) Implemented Base-2 logarithm
Math.log1p(x) Implemented ln(1+x) (precise for small x)

Trigonometric

Method Status Description
Math.sin(x) Implemented Sine
Math.cos(x) Implemented Cosine
Math.tan(x) Implemented Tangent
Math.asin(x) Implemented Arc sine
Math.acos(x) Implemented Arc cosine
Math.atan(x) Implemented Arc tangent
Math.atan2(y, x) Implemented Two-argument arc tangent

Hyperbolic

Method Status Description
Math.sinh(x) Implemented Hyperbolic sine
Math.cosh(x) Implemented Hyperbolic cosine
Math.tanh(x) Implemented Hyperbolic tangent
Math.asinh(x) Implemented Inverse hyperbolic sine
Math.acosh(x) Implemented Inverse hyperbolic cosine
Math.atanh(x) Implemented Inverse hyperbolic tangent

Bitwise and Integer

Method Status Description
Math.clz32(x) Implemented Count leading zeros (32-bit)
Math.imul(a, b) Implemented 32-bit integer multiply
Math.fround(x) Implemented Round to float32
Math.f16round(x) Implemented Round to float16 (ES2024)

Random

Method Status Description
Math.random() Implemented Random [0, 1)

Math Constants

Constant Value Description
Math.E ~2.718 Euler's number
Math.PI ~3.14159 Pi
Math.LN2 ~0.693 Natural log of 2
Math.LN10 ~2.303 Natural log of 10
Math.LOG2E ~1.443 Base-2 log of e
Math.LOG10E ~0.434 Base-10 log of e
Math.SQRT1_2 ~0.707 Square root of 1/2
Math.SQRT2 ~1.414 Square root of 2

Implementation Notes

Global vs Number Methods

// Global versions coerce to number first
isNaN("hello")        // true (coerced to NaN)
Number.isNaN("hello") // false (type-strict)

isFinite("42")        // true (coerced to 42)
Number.isFinite("42") // false (type-strict)

Formatting

All number formatting uses CultureInfo.InvariantCulture for consistent output.

Files

File Purpose
StdLib/Number/NumberConstructor.cs Static methods and constants
StdLib/Number/NumberPrototype.cs Prototype methods
StdLib/Math/MathPrototype.cs Math object methods

See Also

Clone this wiki locally