SST
9.0.0
StructuralSimulationToolkit
|
Class that implements a decimal fixed-point number. More...
#include <decimal_fixedpoint.h>
Public Member Functions | |
constexpr int | getWholeWords () const |
Get the value of whole_words template parameter. | |
constexpr int | getFractionWords () const |
Get the value of fraction_words template parameter. | |
decimal_fixedpoint () | |
Default constructor. More... | |
decimal_fixedpoint (std::string init) | |
Build a decimal_fixedpoint using a string initializer. More... | |
template<class T > | |
decimal_fixedpoint (T init, typename std::enable_if< std::is_unsigned< T >::value >::type *=0) | |
Build a decimal_fixedpoint using a 64-bit unsigned number. More... | |
template<class T > | |
decimal_fixedpoint (T init, typename std::enable_if< std::is_signed< T >::value &&std::is_integral< T >::value >::type *=0) | |
Build a decimal_fixedpoint using a 64-bit signed number. More... | |
template<class T > | |
decimal_fixedpoint (const T init, typename std::enable_if< std::is_floating_point< T >::value >::type *=0) | |
Build a decimal_fixedpoint using a double. More... | |
decimal_fixedpoint (const decimal_fixedpoint &init) | |
Build a decimal_fixedpoint using another decimal_fixedpoint. More... | |
decimal_fixedpoint & | operator= (const decimal_fixedpoint &v) |
Equal operator for other decimal_fixedpoint objects. | |
decimal_fixedpoint & | operator= (uint64_t v) |
Equal operator for 64-bit unsigned int. | |
decimal_fixedpoint & | operator= (int64_t v) |
Equal operator for 64-bit signed int. | |
decimal_fixedpoint & | operator= (double v) |
Equal operator for double. | |
decimal_fixedpoint & | operator= (std::string v) |
Equal operator for string. | |
void | negate () |
Negate the value (change the sign bit). | |
double | toDouble () const |
Return a double precision version of the decimal_fixedpoint. More... | |
int64_t | toLong () const |
Return a int64_t version of the decimal_fixedpoint. More... | |
uint64_t | toUnsignedLong () const |
Return a uint64_t version of the decimal_fixedpoint. More... | |
template<typename T > | |
T | convert_to (typename std::enable_if< std::is_unsigned< T >::value >::type *=0) const |
Templated conversion function for unsigned types. | |
template<typename T > | |
T | convert_to (typename std::enable_if< std::is_signed< T >::value &&std::is_integral< T >::value >::type *=0) const |
Templated conversion function for signed integral types. | |
template<typename T > | |
T | convert_to (typename std::enable_if< std::is_floating_point< T >::value >::type *=0) const |
Templated conversion function for floating point types. | |
std::string | toString (int32_t precision=6) const |
Create a string representation of this decimal_fixedpoint. More... | |
decimal_fixedpoint & | operator+= (const decimal_fixedpoint &v) |
Adds another number to this one and sets it equal to the result. More... | |
decimal_fixedpoint & | operator-= (const decimal_fixedpoint &v) |
Subtracts another number from this one and sets it equal to the result. More... | |
decimal_fixedpoint & | operator*= (const decimal_fixedpoint &v) |
Multiplies another number to this one and sets it equal to the result. More... | |
decimal_fixedpoint & | operator/= (const decimal_fixedpoint &v) |
Divides another number from this one and sets it equal to the result. More... | |
decimal_fixedpoint & | inverse () |
Inverts the number (1 divided by this number) | |
bool | operator== (const decimal_fixedpoint &v) const |
Checks to see if two numbers are equal. More... | |
bool | operator!= (const decimal_fixedpoint &v) const |
Checks to see if two numbers are not equal. More... | |
bool | operator> (const decimal_fixedpoint &v) const |
Checks to see if this number is greater than another number. More... | |
bool | operator>= (const decimal_fixedpoint &v) const |
Checks to see if this number is greater than or equal to another number. More... | |
bool | operator< (const decimal_fixedpoint &v) const |
Checks to see if this number is less than another number. More... | |
bool | operator<= (const decimal_fixedpoint &v) const |
Checks to see if this number is less than or equal to another number. More... | |
Static Public Attributes | |
static constexpr uint32_t | storage_radix = 100000000 |
static constexpr uint64_t | storage_radix_long = 100000000l |
static constexpr int32_t | digits_per_word = 8 |
Friends | |
template<int A, int B> | |
class | sst_dec_fixed |
Class that implements a decimal fixed-point number.
Fixed point class that stores digits in radix-10. Size is specified in words, and each word represents 8 digits.
whole_words | Number of words used to represent the digits to the left of the decimal point. Each word represents 8 decimal digits. |
fraction_words | Number of words used to represent the digits to the right of the decimal point. Each word represents 8 decimal digits. |
|
inline |
Default constructor.
Builds a decimal_fixedpoint with the value 0;
|
inline |
Build a decimal_fixedpoint using a string initializer.
init | Initialization string. The format is similar to the c++ double precision strings. For example 1.234, -1.234, 0.234, 1.234e14, 1.234e14, etc. |
|
inline |
Build a decimal_fixedpoint using a 64-bit unsigned number.
init | Initialization value. |
|
inline |
Build a decimal_fixedpoint using a 64-bit signed number.
init | Initialization value. |
|
inline |
Build a decimal_fixedpoint using a double.
init | Initialization value. |
|
inline |
Build a decimal_fixedpoint using another decimal_fixedpoint.
init | Initialization value. |
|
inline |
Checks to see if two numbers are not equal.
v | Number to check equality against |
|
inline |
Multiplies another number to this one and sets it equal to the result.
v | Number to multiply to this one |
Referenced by SST::decimal_fixedpoint< 3, 3 >::operator/=().
|
inline |
Adds another number to this one and sets it equal to the result.
v | Number to add to this one |
Referenced by SST::decimal_fixedpoint< 3, 3 >::operator-=().
|
inline |
Subtracts another number from this one and sets it equal to the result.
v | Number to subtract from this one |
|
inline |
Divides another number from this one and sets it equal to the result.
v | Number to divide from this one |
|
inline |
Checks to see if this number is less than another number.
v | Number to compare to |
|
inline |
Checks to see if this number is less than or equal to another number.
v | Number to compare to |
|
inline |
Checks to see if two numbers are equal.
v | Number to check equality against |
|
inline |
Checks to see if this number is greater than another number.
v | Number to compare to |
|
inline |
Checks to see if this number is greater than or equal to another number.
v | Number to compare to |
|
inline |
Return a double precision version of the decimal_fixedpoint.
There is possible precision loss in this conversion.
Referenced by SST::decimal_fixedpoint< 3, 3 >::convert_to(), and SST::decimal_fixedpoint< 3, 3 >::inverse().
|
inline |
Return a int64_t version of the decimal_fixedpoint.
There is possible precision loss in this conversion.
Referenced by SST::decimal_fixedpoint< 3, 3 >::convert_to().
|
inline |
Create a string representation of this decimal_fixedpoint.
precision | Precision to use when printing number |
Referenced by SST::UnitAlgebra::toStringBestSI().
|
inline |
Return a uint64_t version of the decimal_fixedpoint.
There is possible precision loss in this conversion.
Referenced by SST::decimal_fixedpoint< 3, 3 >::convert_to().