struct eosio::fixed_point64

Class List > eosio :: fixed_point64

Public Attributes

Type Name
int64_t val

Public Functions

Type Name
fixed_point64 (int64_t v = 0)
fixed_point64 (const fixed_point64< QR > & r)
fixed_point64 (const fixed_point32< QR > & r)
int64_t int_part () const
uint64_t frac_part () const
void print () const
Prints the fixed point value.
fixed_point64 & operator= (const fixed_point32< QR > & r)
fixed_point64 & operator= (const fixed_point64< QR > & r)
fixed_point64<(Q >QR)?Q:QR > operator+ (const fixed_point64< QR > & r) const
fixed_point64<(Q >QR)?Q:QR > operator- (const fixed_point64< QR > & r) const
fixed_point128< Q+QR > operator* (const fixed_point64< QR > & r) const
Multiplication operator for fixed_point64. The result goes to fixed_point64.
fixed_point128< Q+64-QR > operator/ (const fixed_point64< QR > & r) const
bool operator== (const fixed_point64< QR > & r)
bool operator> (const fixed_point64< QR > & r)
bool operator< (const fixed_point64< QR > & r)
fixed_point64<(Q >QR)?Q:QR > operator+ (const fixed_point64< QR > & rhs) const
Addition between two fixed_point64 variables and the result goes to fixed_point64.
fixed_point64<(Q >QR)?Q:QR > operator- (const fixed_point64< QR > & rhs) const
Subtraction between two fixed_point64 variables and the result goes to fixed_point64.

Detailed Description

64 bits representation of Fixed Point class. Example:

fixed_point64<6> a(123232.455667233)
fixed_point64<0> a(123424)
fixed_point64<18> c = a*b;
fixed_point64<24> d = a+b+c;
fixed_point64<24> e = b/a;

Public Attributes Documentation

variable val

int64_t eosio::fixed_point64< Q >::val;

Value of the fixed point represented as int64_t

Public Functions Documentation

function fixed_point64 (1/3)

eosio::fixed_point64< Q >::fixed_point64(
    int64_t v = 0
)

Construct a new fixed point64 object from int64_t

Parameters:

  • v - int64_t representation of the fixed point value

function fixed_point64 (2/3)

template<uint8_t QR>
eosio::fixed_point64< Q >::fixed_point64(
    const fixed_point64< QR > & r
)

Construct a new fixed point64 object from another fixed_point64

Parameters:

function fixed_point64 (3/3)

template<uint8_t QR>
eosio::fixed_point64< Q >::fixed_point64(
    const fixed_point32< QR > & r
)

Construct a new fixed point64 object from another fixed_point32

Parameters:

function int_part

int64_t eosio::fixed_point64< Q >::int_part() const

Get the integer part of the 64 bit fixed number

Returns:

Returns integer part of the fixed number

Example:

fixed_point64<18> a(1234.455667)
std::cout << a.int_part(); // Output: 1234

function frac_part

uint64_t eosio::fixed_point64< Q >::frac_part() const

Get the decimal part of the 64 bit fixed number

Returns:

Returns decimal part of the fixed number

Example:

fixed64<3> a(1234.455667)
std::cout << a.decimal_part(); // Output: 455

function print

void eosio::fixed_point64< Q >::print() const

Prints the fixed point value.

Prints the fixed point value

function operator= (1/2)

template<uint8_t QR>
fixed_point64& eosio::fixed_point64< Q >::operator=(
    const fixed_point32< QR > & r
)

Assignment operator. Assign fixed_point32 to fixed_point64

Template parameters:

  • qr - Precision of the source

Parameters:

  • r - Source

Returns:

fixed_point64& - Reference to this object

function operator= (2/2)

template<uint8_t QR>
fixed_point64& eosio::fixed_point64< Q >::operator=(
    const fixed_point64< QR > & r
)

Assignment operator. Assign fixed_point64 to fixed_point64

Template parameters:

  • qr - Precision of the source

Parameters:

  • r - Source

Returns:

fixed_point64& - Reference to this object

function operator+ (1/2)

template<uint8_t QR>
fixed_point64< (Q>QR)?Q:QR > eosio::fixed_point64< Q >::operator+(
    const fixed_point64< QR > & r
) const

Addition operator

Template parameters:

  • QR - Precision of the second addend

Parameters:

  • r - Second addend

Returns:

  • The result of addition

function operator- (1/2)

template<uint8_t QR>
fixed_point64< (Q>QR)?Q:QR > eosio::fixed_point64< Q >::operator-(
    const fixed_point64< QR > & r
) const

Subtraction operator

Template parameters:

  • QR - Precision of the minuend

Parameters:

  • r - Minuend

Returns:

  • The result of subtraction

function operator*

template<uint8_t QR>
fixed_point128< Q+QR > eosio::fixed_point64< Q >::operator*(
    const fixed_point64< QR > & r
) const

Multiplication operator for fixed_point64. The result goes to fixed_point64.

Multiplication operator

Template parameters:

  • QR - Precision of the multiplier

Parameters:

  • r - Multiplier

Returns:

  • The result of multiplication

Multiplication operator for fixed_point64. The result goes to fixed_point128

Note:

Number of decimal on result will be sum of number of decimals of lhs and rhs

Example:

fixed_point128<33> result = fixed_point64<0>(131313) / fixed_point64<0>(2323)

function operator/

template<uint8_t QR>
fixed_point128< Q+64-QR > eosio::fixed_point64< Q >::operator/(
    const fixed_point64< QR > & r
) const

Division operator

Template parameters:

  • QR - Precision of the divisor

Parameters:

  • r - Divisor

Returns:

  • The result of division

Division of two fixed_point64 result will be stored in fixed_point128 Example:

fixed_point128<33> result = fixed_point64<0>(131313) / fixed_point64<0>(2323)

function operator==

template<uint8_t QR>
bool eosio::fixed_point64< Q >::operator==(
    const fixed_point64< QR > & r
)

Equality operator

Template parameters:

  • qr - Precision of the source

Parameters:

  • r - Source

Returns:

true - if equal

Returns:

false - otherwise

function operator>

template<uint8_t QR>
bool eosio::fixed_point64< Q >::operator>(
    const fixed_point64< QR > & r
)

Greater than operator

Template parameters:

  • qr - Precision of the source

Parameters:

  • r - Source

Returns:

true - if equal

Returns:

false - otherwise

function operator<

template<uint8_t QR>
bool eosio::fixed_point64< Q >::operator<(
    const fixed_point64< QR > & r
)

Less than operator

Template parameters:

  • qr - Precision of the source

Parameters:

  • r - Source

Returns:

true - if equal

Returns:

false - otherwise

function operator+ (2/2)

template<uint8_t QR>
fixed_point64< (Q>QR)?Q:QR > eosio::fixed_point64< Q >::operator+(
    const fixed_point64< QR > & rhs
) const

Addition between two fixed_point64 variables and the result goes to fixed_point64.

Addition between two fixed_point64 variables Number of decimal on result will be max of decimals of lhs and rhs

function operator- (2/2)

template<uint8_t QR>
fixed_point64< (Q>QR)?Q:QR > eosio::fixed_point64< Q >::operator-(
    const fixed_point64< QR > & rhs
) const

Subtraction between two fixed_point64 variables and the result goes to fixed_point64.

Subtraction between two fixed_point64 variables Number of decimal on result will be max of decimals of lhs and rhs


The documentation for this class was generated from the following file: libraries/eosiolib/fixedpoint.hpp