struct eosio::fixed_point128
Class List > eosio :: fixed_point128
Public Attributes
Type | Name |
---|---|
int128_t | val |
Public Functions
Type | Name |
---|---|
fixed_point128 (int128_t v = 0) | |
fixed_point128 (const fixed_point128< qr > & r) | |
fixed_point128 (const fixed_point64< qr > & r) | |
fixed_point128 (const fixed_point32< qr > & r) Construct a new fixed point128 object from another fixed_point32. |
|
int128_t | int_part () const |
uint128_t | frac_part () const |
void | print () const |
fixed_point128 & | operator= (const fixed_point32< qr > & r) |
fixed_point128 & | operator= (const fixed_point64< qr > & r) |
fixed_point128 & | operator= (const fixed_point128< qr > & r) |
bool | operator== (const fixed_point128< qr > & r) |
bool | operator> (const fixed_point128< qr > & r) |
bool | operator< (const fixed_point128< qr > & r) |
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
Public Functions Documentation
function fixed_point128 (1/4)
eosio::fixed_point128< Q >::fixed_point128(
int128_t v = 0
)
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
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
Parameters:
- r - Another fixed_point128 as source
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
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
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
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
function operator= (1/3)
template<uint8_t qr>
fixed_point128& eosio::fixed_point128< Q >::operator=(
const fixed_point32< qr > & r
)
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. 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. 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
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
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
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