toBigInt

Returns a bigint for finite values, or null for non-finite values.

Summary

Use this at system boundaries that require bigint, after deciding which rounding mode should handle fractional values.

AI Contract

FieldValue
Kindinstance method
Canonical nametoBigInt
AliasesNone
Mutates receiverNo
Returns`bigint
Accepts (string, base) overloadNo
Configuration dependenciesROUNDING_MODE
Related methodsintegerValue, toNumber

Signature

toBigInt(roundingMode?: ArithRoundingMode): bigint | null;

Parameters

ParameterTypeRequiredNotes
roundingModeArithRoundingModeNoDefaults to current ROUNDING_MODE.

Returns

Returns a bigint when the receiver is finite; returns null for NaN and infinities.

Behavior

  • Rounds non-integer finite values using roundingMode or current ROUNDING_MODE.
  • Non-finite values return null.
  • The receiver is not modified.

Examples

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

new Arith("10.8").toBigInt(Arith.ROUND_FLOOR); // 10n

Errors

  • Throws if 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