Returns ceil(this × numerator / denominator) using integer arithmetic only.
The default denominator of 100 makes common percentage calculations natural. Use a larger denominator to express fractional percentages without floats.
Clamps this amount to the inclusive range [min, max].
Compares this Amount with another Amount.
Defines the natural ordering of Amount values. Useful for sorting and ordering logic.
-1 if this < other, 0 if equal, 1 if this > other.
Returns floor(this × numerator / denominator) using integer arithmetic only.
The natural complement to Amount.ceilPercent — use when you need the conservative lower bound, e.g. "maximum spendable after reserving fees".
Returns true if this amount is within the inclusive range [min, max].
Whether this Amount can be safely converted to a number.
Returns round(this × numerator / denominator) using integer arithmetic only.
Useful for proportional rescaling — currency conversion, capacity checks, partial fills — without floating-point imprecision or overflow risk.
Uses the identity: round(a × b / c) = floor((2 × a × b + c) / (2 × c))
Internal canonical value.
Returns number if a safe integer, string if not.
Unsafe conversion to number. Precision can be lost above MAX_SAFE_INTEGER.
Canonical decimal representation for logs/JSON string mode.
StaticfromStaticmaxStaticminStaticoneStaticsumStaticzero
Immutable, non-negative integer amount value object.
Internal representation is bigint. Use factory methods to instantiate.
Example