shiftedBy

Returns this * 10^n.

Human Summary

Use it for decimal scale changes such as cents-to-dollars or percentage basis-point shifts.

AI Contract

FieldValue
Kindinstance method
Canonical nameshiftedBy
AliasesNone
Mutates receiverNo
ReturnsArithInstance
Accepts (string, base) overloadNo
Configuration dependenciesNone
Related methodstimes

Signature

shiftedBy(n: number): ArithInstance;

Parameters

ParameterTypeRequiredNotes
nnumberYesInteger shift count. Positive shifts right; negative shifts left.

Returns

Returns a new Arith instance.

Behavior

  • Positive n moves the decimal point right.
  • Negative n moves the decimal point left.
  • Equivalent to multiplying by 1e${n} with Arith arithmetic.

Examples

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

new Arith("1.23").shiftedBy(2).toString(); // "123"
new Arith("123").shiftedBy(-2).toString(); // "1.23"

Errors

  • Throws if n is not an integer in the safe supported range.

Agent Notes

  • Prefer shiftedBy over manual string decimal-point manipulation.
  • 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