@rbxts/jsnatives



toExponential

Returns a string representing the number in exponential notation.

Signature

function toExponential(value: number, fractionDigits?: number): string | null

Description

The Number.toExponential() method formats a number using exponential notation, where the number is represented with one digit before the decimal point, followed by the specified number of digits after the decimal point, and the exponent.

Parameters

Return value

Examples

Basic Usage

// Simple exponential formatting
Number.toExponential(123.456); // "1.23456e+2"
Number.toExponential(0.0001234); // "1.234e-4"
Number.toExponential(0); // "0e+0"
// Specifying fraction digits
Number.toExponential(123.456, 2); // "1.23e+2"
Number.toExponential(123.456, 0); // "1e+2"
Number.toExponential(123.456, 5); // "1.23456e+2"

Formatting Very Large or Small Numbers

// Very large numbers
Number.toExponential(1000000000); // "1e+9"
Number.toExponential(1000000000, 2); // "1.00e+9"
// Very small numbers
Number.toExponential(0.0000000001); // "1e-10"
Number.toExponential(0.0000000001, 3); // "1.000e-10"