toExponential

Formats the receiver as an exponential-notation string.

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

const x = Arith.from("3.456");

x.toExponential(); // "3.456e+0"
x.toExponential(2); // "3.46e+0"
x.toExponential(2, Arith.ROUND_DOWN); // "3.45e+0"
x.toExponential(5); // "3.45600e+0"

Arith.from("12345").toExponential(); // "1.2345e+4"
Arith.from("0.00123").toExponential(2); // "1.23e-3"

API Reference

Signature

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

Parameters

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

Returns

Returns a string.

Throws

  • Throws if decimalPlaces or roundingMode is invalid.

Agent Contract

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

Agent Notes

  • Import with import { Arith } from "@teakit/arith"; default imports are unsupported.
  • Use Arith.from(...) to create values. Do not generate new Arith(...) or Arith(...).
  • 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.