Class List > eosio :: fixed_point128

128 bits representation of Fixed Point class. More...

Public Attributes

Type Name
int128_t val
Value of the fixed point represented as int128_t.

Public Functions

Type Name
fixed_point128 (int128_t v = 0)
Various constructors for fixed_point128.
fixed_point128 (const fixed_point128< qr > & r)
Construct a new fixed point128 object from another fixed_point128.
fixed_point128 (const fixed_point64< qr > & r)
Construct a new fixed point128 object from another fixed_point64.
fixed_point128 (const fixed_point32< qr > & r)
Construct a new fixed point128 object from another fixed_point32.
int128_t int_part () const
To get the integer part of the fixed number.
uint128_t frac_part () const
To get the decimal part of the fixed number.
void print () const
Prints the fixed point value.
fixed_point128 & operator= (const fixed_point32< qr > & r)
Assignment operator.
fixed_point128 & operator= (const fixed_point64< qr > & r)
Assignment operator.
fixed_point128 & operator= (const fixed_point128< qr > & r)
Assignment operator.
bool operator== (const fixed_point128< qr > & r)
Equality operator.
bool operator> (const fixed_point128< qr > & r)
Greater than operator.
bool operator< (const fixed_point128< qr > & r)
Less than operator.

Detailed Description

The template param Q represents the Q Factor i.e number of decimals Example:

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

Public Attributes Documentation

variable val

int128_t eosio::fixed_point128< Q >::val;

Value of the fixed point represented as int128_t.

Value of the fixed point represented as int128_t

Public Functions Documentation

function fixed_point128 (1/4)

eosio::fixed_point128< Q >::fixed_point128(
    int128_t v = 0
)

Various constructors for fixed_point128.

Various constructors for fixed_point128. Can create fixed_point128 instance from an int128_t, fixed_point128,64,32 instance Example:

fixed_point64<18> a(1234.455667);
fixed_point128<3> b(a);
fixed_point32<6> b(13324.32323);
fixed_point128<5> c(a);

Construct a new fixed point128 object from int128_t Construct a new fixed point128 object

Parameters:

  • v - int128_t representation of the fixed point value

function fixed_point128 (2/4)

template<uint8_t qr>
eosio::fixed_point128< Q >::fixed_point128(
    const fixed_point128< qr > & r
)

Construct a new fixed point128 object from another fixed_point128.

Construct a new fixed point128 object from another fixed_point128

Parameters:

function fixed_point128 (3/4)

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

Construct a new fixed point128 object from another fixed_point64.

Construct a new fixed point128 object from another fixed_point64

Parameters:

  • r -fixed_point64 as source

function fixed_point128 (4/4)

template<uint8_t qr>
eosio::fixed_point128< Q >::fixed_point128(
    const fixed_point32< qr > & r
)

Construct a new fixed point128 object from another fixed_point32.

Construct a new fixed point128 object from another fixed_point32

Parameters:

  • r -fixed_point32 as source

function int_part

int128_t eosio::fixed_point128< Q >::int_part() const

To get the integer part of the fixed number.

Get the integer part of the 64 bit fixed number

Returns:

Returns integer part of the fixed number

Example:

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

function frac_part

uint128_t eosio::fixed_point128< Q >::frac_part() const

To get the decimal part of the fixed number.

Get the decimal part of the 64 bit fixed number

Returns:

Returns decimal part of the fixed number

Example:

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

function print

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

Prints the fixed point value.

Prints the fixed point value

function operator= (1/3)

template<uint8_t qr>
fixed_point128& eosio::fixed_point128< Q >::operator=(
    const fixed_point32< qr > & r
)

Assignment operator.

Assignment operator. Assign fixed_point32 to fixed_point128

Template parameters:

  • qr - Precision of the source

Parameters:

  • r - Source

Returns:

fixed_point128& - Reference to this object

function operator= (2/3)

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

Assignment operator.

Assignment operator. Assign fixed_point32 to fixed_point64

Template parameters:

  • qr - Precision of the source

Parameters:

  • r - Source

Returns:

fixed_point128& - Reference to this object

function operator= (3/3)

template<uint8_t qr>
fixed_point128& eosio::fixed_point128< Q >::operator=(
    const fixed_point128< qr > & r
)

Assignment operator.

Assignment operator. Assign fixed_point32 to fixed_point32

Template parameters:

  • qr - Precision of the source

Parameters:

  • r - Source

Returns:

fixed_point128& - Reference to this object

function operator==

template<uint8_t qr>
bool eosio::fixed_point128< Q >::operator==(
    const fixed_point128< qr > & r
)

Equality operator.

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_point128< Q >::operator>(
    const fixed_point128< qr > & r
)

Greater than operator.

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_point128< Q >::operator<(
    const fixed_point128< qr > & r
)

Less than operator.

Less than operator

Template parameters:

  • qr - Precision of the source

Parameters:

  • r - Source

Returns:

true - if equal

Returns:

false - otherwise


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