|
rippled
|
MantissaRange defines a range for the mantissa of a normalized Number. More...
#include <Number.h>

Public Types | |
| enum | mantissa_scale { small , large } |
| using | rep = std::uint64_t |
Public Member Functions | |
| constexpr | MantissaRange (mantissa_scale scale_) |
Public Attributes | |
| rep | min |
| rep | max |
| int | log |
| mantissa_scale | scale |
Static Private Member Functions | |
| static constexpr rep | getMin (mantissa_scale scale_) |
MantissaRange defines a range for the mantissa of a normalized Number.
The mantissa is in the range [min, max], where
The mantissa_scale enum indicates whether the range is "small" or "large". This intentionally restricts the number of MantissaRanges that can be instantiated to two: 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" scale is 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.
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.
|
explicitconstexpr |
|
staticconstexprprivate |
| mantissa_scale xrpl::MantissaRange::scale |