Expand description
The one amount grammar of the transaction forms.
An amount is a decimal (10.5, -3, +.25) or an exact fraction
a/b (optional sign on a, positive integer b). It parses into a
reduced (numerator, denominator) pair of i64, with no floating point.
Enums§
Functions§
- display
- Display text of
num/denom: the exact decimal or fraction, falling back to the wire token (n/0for a zero denominator). - format_
amount - Renders
num/denomso the amount parser reads back the same reduced value: the exact decimal when it terminates and the parser accepts it, otherwise the reduced fractiona/b. Never rounds.Nonefor a zero denominator or a value the parser cannot hold. - parse_
amount - Parses an amount into a reduced
(numerator, denominator); the denominator is positive and the numerator is neveri64::MIN. - reduce_
to_ i64 - Reduces
num/denomby their gcd and narrows it toi64;denommust be positive. Fails withOverflowwhen either part does not fit, or the numerator isi64::MIN. - wire_
rational - Wire token of a
Rational64; a zero-denominator ratio (constructible only unchecked) renders asn/0, which the reader rejects instead of misreading. - wire_
token - Wire token for the nomiscript reader: the reduced
nfor a whole value, elsen/dwith the sign onn.Nonefor a zero denominator.