Files | |
file | fixed_point.hpp |
Class definition for fixed point data type. | |
file | fixed_point.hpp |
Class definition for fixed point data type. | |
Classes | |
struct | numeric::scaled_integer< Rep, > |
Helper struct for constructing fixed_point when value is already shifted. More... | |
class | numeric::fixed_point< Rep, Rad > |
A type for representing a number with a fixed amount of precision. More... | |
Typedefs | |
using | numeric::decimal32 = fixed_point< int32_t, Radix::BASE_10 > |
32-bit decimal fixed point | |
using | numeric::decimal64 = fixed_point< int64_t, Radix::BASE_10 > |
64-bit decimal fixed point | |
using | numeric::decimal128 = fixed_point< __int128_t, Radix::BASE_10 > |
128-bit decimal fixed point | |
Enumerations | |
enum | numeric::scale_type : int32_t |
The scale type for fixed_point. | |
enum class | numeric::Radix : int32_t { BASE_2 = 2 , BASE_10 = 10 } |
Scoped enumerator to use when constructing fixed_point More... | |
Functions | |
template<typename T > | |
constexpr auto | numeric::is_supported_representation_type () |
Returns true if the representation type is supported by fixed_point More... | |
template<typename Rep , typename T > | |
CUDF_HOST_DEVICE auto | numeric::addition_overflow (T lhs, T rhs) |
Function for identifying integer overflow when adding. More... | |
template<typename Rep , typename T > | |
CUDF_HOST_DEVICE auto | numeric::subtraction_overflow (T lhs, T rhs) |
Function for identifying integer overflow when subtracting. More... | |
template<typename Rep , typename T > | |
CUDF_HOST_DEVICE auto | numeric::division_overflow (T lhs, T rhs) |
Function for identifying integer overflow when dividing. More... | |
template<typename Rep , typename T > | |
CUDF_HOST_DEVICE auto | numeric::multiplication_overflow (T lhs, T rhs) |
Function for identifying integer overflow when multiplying. More... | |
template<typename Rep1 , Radix Rad1> | |
CUDF_HOST_DEVICE fixed_point< Rep1, Rad1 > | numeric::operator+ (fixed_point< Rep1, Rad1 > const &lhs, fixed_point< Rep1, Rad1 > const &rhs) |
template<typename Rep1 , Radix Rad1> | |
CUDF_HOST_DEVICE fixed_point< Rep1, Rad1 > | numeric::operator- (fixed_point< Rep1, Rad1 > const &lhs, fixed_point< Rep1, Rad1 > const &rhs) |
template<typename Rep1 , Radix Rad1> | |
CUDF_HOST_DEVICE fixed_point< Rep1, Rad1 > | numeric::operator* (fixed_point< Rep1, Rad1 > const &lhs, fixed_point< Rep1, Rad1 > const &rhs) |
template<typename Rep1 , Radix Rad1> | |
CUDF_HOST_DEVICE fixed_point< Rep1, Rad1 > | numeric::operator/ (fixed_point< Rep1, Rad1 > const &lhs, fixed_point< Rep1, Rad1 > const &rhs) |
template<typename Rep1 , Radix Rad1> | |
CUDF_HOST_DEVICE bool | numeric::operator== (fixed_point< Rep1, Rad1 > const &lhs, fixed_point< Rep1, Rad1 > const &rhs) |
template<typename Rep1 , Radix Rad1> | |
CUDF_HOST_DEVICE bool | numeric::operator!= (fixed_point< Rep1, Rad1 > const &lhs, fixed_point< Rep1, Rad1 > const &rhs) |
template<typename Rep1 , Radix Rad1> | |
CUDF_HOST_DEVICE bool | numeric::operator<= (fixed_point< Rep1, Rad1 > const &lhs, fixed_point< Rep1, Rad1 > const &rhs) |
template<typename Rep1 , Radix Rad1> | |
CUDF_HOST_DEVICE bool | numeric::operator>= (fixed_point< Rep1, Rad1 > const &lhs, fixed_point< Rep1, Rad1 > const &rhs) |
template<typename Rep1 , Radix Rad1> | |
CUDF_HOST_DEVICE bool | numeric::operator< (fixed_point< Rep1, Rad1 > const &lhs, fixed_point< Rep1, Rad1 > const &rhs) |
template<typename Rep1 , Radix Rad1> | |
CUDF_HOST_DEVICE bool | numeric::operator> (fixed_point< Rep1, Rad1 > const &lhs, fixed_point< Rep1, Rad1 > const &rhs) |
template<typename Rep1 , Radix Rad1> | |
CUDF_HOST_DEVICE fixed_point< Rep1, Rad1 > | numeric::operator% (fixed_point< Rep1, Rad1 > const &lhs, fixed_point< Rep1, Rad1 > const &rhs) |
|
strong |
Scoped enumerator to use when constructing fixed_point
Examples:
Definition at line 54 of file fixed_point.hpp.
|
inline |
Function for identifying integer overflow when adding.
Rep | Type of integer to check for overflow on |
T | Types of lhs and rhs (ensures they are the same type) |
lhs | Left hand side of addition |
rhs | Right hand side of addition |
Definition at line 614 of file fixed_point.hpp.
|
inline |
Function for identifying integer overflow when dividing.
Rep | Type of integer to check for overflow on |
T | Types of lhs and rhs (ensures they are the same type) |
lhs | Left hand side of division |
rhs | Right hand side of division |
Definition at line 644 of file fixed_point.hpp.
|
inlineconstexpr |
Returns true
if the representation type is supported by fixed_point
T | The representation type |
true
if the type is supported by fixed_point
implementation Definition at line 63 of file fixed_point.hpp.
|
inline |
Function for identifying integer overflow when multiplying.
Rep | Type of integer to check for overflow on |
T | Types of lhs and rhs (ensures they are the same type) |
lhs | Left hand side of multiplication |
rhs | Right hand side of multiplication |
Definition at line 658 of file fixed_point.hpp.
|
inline |
If _scale
s are equal, _value
s are compared. If _scale
s are not equal, the number with the larger _scale
is shifted to the smaller _scale
, and then the _value
s are compared.
Rep1 | Representation type of the operand lhs and rhs |
Rad1 | Radix (base) type of the operand lhs and rhs |
lhs | The left hand side operand |
rhs | The right hand side operand |
lhs
and rhs
are not equal, false if not Definition at line 744 of file fixed_point.hpp.
|
inline |
If _scale
s are equal, the modulus is computed directly. If _scale
s are not equal, the number with larger _scale
is shifted to the smaller _scale
, and then the modulus is computed.
Rep1 | Representation type of the operand lhs and rhs |
Rad1 | Radix (base) type of the operand lhs and rhs |
lhs | The left hand side operand |
rhs | The right hand side operand |
fixed_point
number Definition at line 789 of file fixed_point.hpp.
|
inline |
_scale
s are added and _value
s are multiplied.
Rep1 | Representation type of the operand lhs and rhs |
Rad1 | Radix (base) type of the operand lhs and rhs |
lhs | The left hand side operand |
rhs | The right hand side operand |
fixed_point
product Definition at line 705 of file fixed_point.hpp.
|
inline |
If _scale
s are equal, _value
s are added. If _scale
s are not equal, the number with the larger _scale
is shifted to the smaller _scale
, and then the _value
s are added.
Rep1 | Representation type of the operand lhs and rhs |
Rad1 | Radix (base) type of the operand lhs and rhs |
lhs | The left hand side operand |
rhs | The right hand side operand |
fixed_point
sum Definition at line 669 of file fixed_point.hpp.
|
inline |
If _scale
s are equal, _value
s are subtracted. If _scale
s are not equal, the number with the larger _scale
is shifted to the smaller _scale
, and then the _value
s are subtracted.
Rep1 | Representation type of the operand lhs and rhs |
Rad1 | Radix (base) type of the operand lhs and rhs |
lhs | The left hand side operand |
rhs | The right hand side operand |
fixed_point
difference Definition at line 687 of file fixed_point.hpp.
|
inline |
_scale
s are subtracted and _value
s are divided.
Rep1 | Representation type of the operand lhs and rhs |
Rad1 | Radix (base) type of the operand lhs and rhs |
lhs | The left hand side operand |
rhs | The right hand side operand |
fixed_point
quotient Definition at line 720 of file fixed_point.hpp.
|
inline |
If _scale
s are equal, _value
s are compared. If _scale
s are not equal, the number with the larger _scale
is shifted to the smaller _scale
, and then the _value
s are compared.
Rep1 | Representation type of the operand lhs and rhs |
Rad1 | Radix (base) type of the operand lhs and rhs |
lhs | The left hand side operand |
rhs | The right hand side operand |
lhs
less than rhs
, false if not Definition at line 771 of file fixed_point.hpp.
|
inline |
If _scale
s are equal, _value
s are compared. If _scale
s are not equal, the number with the larger _scale
is shifted to the smaller _scale
, and then the _value
s are compared.
Rep1 | Representation type of the operand lhs and rhs |
Rad1 | Radix (base) type of the operand lhs and rhs |
lhs | The left hand side operand |
rhs | The right hand side operand |
lhs
less than or equal to rhs
, false if not Definition at line 753 of file fixed_point.hpp.
|
inline |
If _scale
s are equal, _value
s are compared. If _scale
s are not equal, the number with the larger _scale
is shifted to the smaller _scale
, and then the _value
s are compared.
Rep1 | Representation type of the operand lhs and rhs |
Rad1 | Radix (base) type of the operand lhs and rhs |
lhs | The left hand side operand |
rhs | The right hand side operand |
lhs
and rhs
are equal, false if not Definition at line 735 of file fixed_point.hpp.
|
inline |
If _scale
s are equal, _value
s are compared. If _scale
s are not equal, the number with the larger _scale
is shifted to the smaller _scale
, and then the _value
s are compared.
Rep1 | Representation type of the operand lhs and rhs |
Rad1 | Radix (base) type of the operand lhs and rhs |
lhs | The left hand side operand |
rhs | The right hand side operand |
lhs
greater than rhs
, false if not Definition at line 780 of file fixed_point.hpp.
|
inline |
If _scale
s are equal, _value
s are compared. If _scale
s are not equal, the number with the larger _scale
is shifted to the smaller _scale
, and then the _value
s are compared.
Rep1 | Representation type of the operand lhs and rhs |
Rad1 | Radix (base) type of the operand lhs and rhs |
lhs | The left hand side operand |
rhs | The right hand side operand |
lhs
greater than or equal to rhs
, false if not Definition at line 762 of file fixed_point.hpp.
|
inline |
Function for identifying integer overflow when subtracting.
Rep | Type of integer to check for overflow on |
T | Types of lhs and rhs (ensures they are the same type) |
lhs | Left hand side of subtraction |
rhs | Right hand side of subtraction |
Definition at line 629 of file fixed_point.hpp.