rippled
Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
ripple::Number Class Reference
Collaboration diagram for ripple::Number:
Collaboration graph
[legend]

Classes

class  Guard
 
struct  unchecked
 

Public Types

enum  rounding_mode { to_nearest, towards_zero, downward, upward }
 

Public Member Functions

constexpr Number ()=default
 
 Number (rep mantissa)
 
 Number (rep mantissa, int exponent)
 
constexpr Number (rep mantissa, int exponent, unchecked) noexcept
 
 Number (XRPAmount const &x)
 
constexpr rep mantissa () const noexcept
 
constexpr int exponent () const noexcept
 
constexpr Number operator+ () const noexcept
 
constexpr Number operator- () const noexcept
 
Numberoperator++ ()
 
Number operator++ (int)
 
Numberoperator-- ()
 
Number operator-- (int)
 
Numberoperator+= (Number const &x)
 
Numberoperator-= (Number const &x)
 
Numberoperator*= (Number const &x)
 
Numberoperator/= (Number const &x)
 
 operator XRPAmount () const
 
 operator rep () const
 

Static Public Member Functions

static constexpr Number min () noexcept
 
static constexpr Number max () noexcept
 
static constexpr Number lowest () noexcept
 
static rounding_mode getround ()
 
static rounding_mode setround (rounding_mode mode)
 

Private Types

using rep = std::int64_t
 

Private Member Functions

void normalize ()
 
constexpr bool isnormal () const noexcept
 

Private Attributes

rep mantissa_ {0}
 
int exponent_ {std::numeric_limits<int>::lowest()}
 

Static Private Attributes

static thread_local rounding_mode mode_ = Number::to_nearest
 
constexpr static std::int64_t minMantissa = 1'000'000'000'000'000LL
 
constexpr static std::int64_t maxMantissa = 9'999'999'999'999'999LL
 
constexpr static int minExponent = -32768
 
constexpr static int maxExponent = 32768
 

Friends

constexpr friend bool operator== (Number const &x, Number const &y) noexcept
 
constexpr friend bool operator!= (Number const &x, Number const &y) noexcept
 
constexpr friend bool operator< (Number const &x, Number const &y) noexcept
 
constexpr friend bool operator> (Number const &x, Number const &y) noexcept
 
constexpr friend bool operator<= (Number const &x, Number const &y) noexcept
 
constexpr friend bool operator>= (Number const &x, Number const &y) noexcept
 
std::ostreamoperator<< (std::ostream &os, Number const &x)
 

Detailed Description

Definition at line 36 of file Number.h.

Member Typedef Documentation

◆ rep

Definition at line 38 of file Number.h.

Member Enumeration Documentation

◆ rounding_mode

Enumerator
to_nearest 
towards_zero 
downward 
upward 

Definition at line 161 of file Number.h.

Constructor & Destructor Documentation

◆ Number() [1/5]

constexpr ripple::Number::Number ( )
explicitconstexprdefault

◆ Number() [2/5]

ripple::Number::Number ( rep  mantissa)

Definition at line 198 of file Number.h.

◆ Number() [3/5]

ripple::Number::Number ( rep  mantissa,
int  exponent 
)
explicit

Definition at line 192 of file Number.h.

◆ Number() [4/5]

constexpr ripple::Number::Number ( rep  mantissa,
int  exponent,
unchecked   
)
explicitconstexprnoexcept

Definition at line 187 of file Number.h.

◆ Number() [5/5]

ripple::Number::Number ( XRPAmount const &  x)

Definition at line 202 of file Number.h.

Member Function Documentation

◆ mantissa()

constexpr Number::rep ripple::Number::mantissa ( ) const
constexprnoexcept

Definition at line 207 of file Number.h.

◆ exponent()

constexpr int ripple::Number::exponent ( ) const
constexprnoexcept

Definition at line 213 of file Number.h.

◆ operator+()

constexpr Number ripple::Number::operator+ ( ) const
constexprnoexcept

Definition at line 219 of file Number.h.

◆ operator-()

constexpr Number ripple::Number::operator- ( ) const
constexprnoexcept

Definition at line 225 of file Number.h.

◆ operator++() [1/2]

Number & ripple::Number::operator++ ( )

Definition at line 233 of file Number.h.

◆ operator++() [2/2]

Number ripple::Number::operator++ ( int  )

Definition at line 240 of file Number.h.

◆ operator--() [1/2]

Number & ripple::Number::operator-- ( )

Definition at line 248 of file Number.h.

◆ operator--() [2/2]

Number ripple::Number::operator-- ( int  )

Definition at line 255 of file Number.h.

◆ operator+=()

Number & ripple::Number::operator+= ( Number const &  x)

Definition at line 224 of file Number.cpp.

◆ operator-=()

Number & ripple::Number::operator-= ( Number const &  x)

Definition at line 263 of file Number.h.

◆ operator*=()

Number & ripple::Number::operator*= ( Number const &  x)

Definition at line 368 of file Number.cpp.

◆ operator/=()

Number & ripple::Number::operator/= ( Number const &  x)

Definition at line 436 of file Number.cpp.

◆ min()

constexpr Number ripple::Number::min ( )
staticconstexprnoexcept

Definition at line 301 of file Number.h.

◆ max()

constexpr Number ripple::Number::max ( )
staticconstexprnoexcept

Definition at line 307 of file Number.h.

◆ lowest()

constexpr Number ripple::Number::lowest ( )
staticconstexprnoexcept

Definition at line 313 of file Number.h.

◆ operator XRPAmount()

ripple::Number::operator XRPAmount ( ) const
explicit

Definition at line 502 of file Number.cpp.

◆ operator rep()

ripple::Number::operator rep ( ) const
explicit

Definition at line 468 of file Number.cpp.

◆ getround()

Number::rounding_mode ripple::Number::getround ( )
static

Definition at line 41 of file Number.cpp.

◆ setround()

Number::rounding_mode ripple::Number::setround ( rounding_mode  mode)
static

Definition at line 47 of file Number.cpp.

◆ normalize()

void ripple::Number::normalize ( )
private

Definition at line 172 of file Number.cpp.

◆ isnormal()

constexpr bool ripple::Number::isnormal ( ) const
constexprprivatenoexcept

Definition at line 319 of file Number.h.

Friends And Related Function Documentation

◆ operator==

constexpr friend bool operator== ( Number const &  x,
Number const &  y 
)
friend

Definition at line 95 of file Number.h.

◆ operator!=

constexpr friend bool operator!= ( Number const &  x,
Number const &  y 
)
friend

Definition at line 101 of file Number.h.

◆ operator<

constexpr friend bool operator< ( Number const &  x,
Number const &  y 
)
friend

Definition at line 107 of file Number.h.

◆ operator>

constexpr friend bool operator> ( Number const &  x,
Number const &  y 
)
friend

Definition at line 137 of file Number.h.

◆ operator<=

constexpr friend bool operator<= ( Number const &  x,
Number const &  y 
)
friend

Definition at line 143 of file Number.h.

◆ operator>=

constexpr friend bool operator>= ( Number const &  x,
Number const &  y 
)
friend

Definition at line 149 of file Number.h.

◆ operator<<

std::ostream& operator<< ( std::ostream os,
Number const &  x 
)
friend

Definition at line 155 of file Number.h.

Member Data Documentation

◆ mantissa_

rep ripple::Number::mantissa_ {0}
private

Definition at line 39 of file Number.h.

◆ exponent_

int ripple::Number::exponent_ {std::numeric_limits<int>::lowest()}
private

Definition at line 40 of file Number.h.

◆ mode_

thread_local Number::rounding_mode ripple::Number::mode_ = Number::to_nearest
staticprivate

Definition at line 169 of file Number.h.

◆ minMantissa

constexpr static std::int64_t ripple::Number::minMantissa = 1'000'000'000'000'000LL
staticconstexprprivate

Definition at line 177 of file Number.h.

◆ maxMantissa

constexpr static std::int64_t ripple::Number::maxMantissa = 9'999'999'999'999'999LL
staticconstexprprivate

Definition at line 178 of file Number.h.

◆ minExponent

constexpr static int ripple::Number::minExponent = -32768
staticconstexprprivate

Definition at line 181 of file Number.h.

◆ maxExponent

constexpr static int ripple::Number::maxExponent = 32768
staticconstexprprivate

Definition at line 182 of file Number.h.