toExponential

Returns a string in exponential notation.

Human Summary

Use it when output should always be exponential, regardless of EXPONENTIAL_AT.

AI Contract

FieldValue
Kindinstance method
Canonical nametoExponential
AliasesNone
Mutates receiverNo
Returnsstring
Accepts (string, base) overloadNo
Configuration dependenciesROUNDING_MODE
Related methodstoFixed, toPrecision, toString

Signature

toExponential(decimalPlaces?: number, roundingMode?: ArithRoundingMode): string;

Parameters

ParameterTypeRequiredNotes
decimalPlacesnumberNoDigits after the decimal point.
roundingModeArithRoundingModeNoDefaults to current ROUNDING_MODE.

Returns

Returns a string.

Behavior

  • Always uses exponential notation for finite values.
  • When decimalPlaces is supplied, rounds to that many places after the decimal point.
  • Uses current ROUNDING_MODE when roundingMode is omitted.

Examples

import { Arith } from "@teakit/arith";

new Arith("12345").toExponential(2); // "1.23e+4"

Errors

  • Throws if decimalPlaces or roundingMode is invalid.

Agent Notes

  • Import from @teakit/arith; prefer import { Arith } from "@teakit/arith".
  • Use new Arith(...) to construct values. Do not generate Arith(...) as a function call.
  • Use string inputs for exact decimal values, especially money-like values.
  • Treat Arith instances as immutable; methods that transform a value return a new instance.
  • Do not mutate internal fields such as c, e, s, or _isArith.

See Also