MantissaRange defines a range for the mantissa of a normalized Number.
The mantissa is in the range [min, max], where
- min is a power of 10, and
- max = min * 10 - 1.
The MantissaScale enum indicates properties of the range: size, and some behavioral options. This intentionally restricts the number of unique MantissaRanges that can be instantiated: one for each scale.
The "Small" scale is based on the behavior of STAmount for IOUs. It has a min value of 10^15, and a max value of 10^16-1. This was sufficient for uses before Lending Protocol was implemented, mostly related to AMM.
However, it does not have sufficient precision to represent the full integer range of int64_t values (-2^63 to 2^63-1), which are needed for XRP and MPT values. The implementation of SingleAssetVault, and LendingProtocol need to represent those integer values accurately and precisely, both for the STNumber field type, and for internal calculations. That necessitated the "large" scale.
The "Large" scales are intended to represent all values that can be represented by an STAmount - IOUs, XRP, and MPTs. It has a min value of 10^18, and a max value of 10^19-1. "LargeLegacy" is like "Large", but preserves a rounding error when a computation results in a mantissa of Number::kMaxRep that needs to be rounded up, but rounds down instead. It will maintain consistent behavior until the fixCleanup3_2_0 amendment is enabled.
Note that if the mentioned amendments are eventually retired, this class should be left in place, but the "Small" scale option should be removed. This will allow for future expansion beyond 64-bits if it is ever needed.
Definition at line 119 of file Number.h.