表示具有固定精度值的类型。 更多...
#include <fixed_point.hpp>
公共类型 | |
using | rep = Rep |
表示类型。 | |
公共成员函数 | |
template<typename T , typename cuda::std::enable_if_t< cuda::std::is_integral_v< T > &&is_supported_representation_type< Rep >()> * = nullptr> | |
CUDF_HOST_DEVICE | fixed_point (T const &value, scale_type const &scale) |
此构造函数将执行移位以适当存储值(从整数类型转换) 更多... | |
CUDF_HOST_DEVICE | fixed_point (scaled_integer< Rep > s) |
此构造函数不会执行移位(假定值已移位) 更多... | |
template<typename T , typename cuda::std::enable_if_t< cuda::std::is_integral_v< T >> * = nullptr> | |
CUDF_HOST_DEVICE | fixed_point (T const &value) |
“无比例”构造函数,使用指定值和零比例构造 fixed_point 数。 更多... | |
CUDF_HOST_DEVICE | fixed_point () |
默认构造函数,使用值和零比例构造 fixed_point 数。 | |
template<typename U , typename cuda::std::enable_if_t< cuda::std::is_integral_v< U >> * = nullptr> | |
constexpr CUDF_HOST_DEVICE | operator U () const |
显式转换运算符,用于转换为整数类型。 更多... | |
CUDF_HOST_DEVICE | operator scaled_integer< Rep > () const |
将 fixed_point 数转换为 scaled_integer 更多... | |
CUDF_HOST_DEVICE rep | value () const |
返回 fixed_point 数底层值的方法。 更多... | |
CUDF_HOST_DEVICE scale_type | scale () const |
返回 fixed_point 数比例的方法。 更多... | |
constexpr CUDF_HOST_DEVICE | operator bool () const |
显式转换为 bool 的运算符。 更多... | |
template<typename Rep1 , Radix Rad1> | |
CUDF_HOST_DEVICE fixed_point< Rep1, Rad1 > & | operator+= (fixed_point< Rep1, Rad1 > const &rhs) |
运算符 += 更多... | |
template<typename Rep1 , Radix Rad1> | |
CUDF_HOST_DEVICE fixed_point< Rep1, Rad1 > & | operator*= (fixed_point< Rep1, Rad1 > const &rhs) |
运算符 *= 更多... | |
template<typename Rep1 , Radix Rad1> | |
CUDF_HOST_DEVICE fixed_point< Rep1, Rad1 > & | operator-= (fixed_point< Rep1, Rad1 > const &rhs) |
运算符 -= 更多... | |
template<typename Rep1 , Radix Rad1> | |
CUDF_HOST_DEVICE fixed_point< Rep1, Rad1 > & | operator/= (fixed_point< Rep1, Rad1 > const &rhs) |
运算符 /= 更多... | |
CUDF_HOST_DEVICE fixed_point< Rep, Rad > & | operator++ () |
运算符 ++(后置增量) 更多... | |
CUDF_HOST_DEVICE fixed_point< Rep, Rad > | rescaled (scale_type scale) const |
创建具有新 scale 的 fixed_point 数的方法。 更多... | |
operator std::string () const | |
返回 fixed_point 值的字符串表示。 | |
静态公共属性 | |
static constexpr auto | rad = Rad |
基数。 | |
友元 | |
template<typename Rep1 , Radix Rad1> | |
CUDF_HOST_DEVICE friend fixed_point< Rep1, Rad1 > | operator+ (fixed_point< Rep1, Rad1 > const &lhs, fixed_point< Rep1, Rad1 > const &rhs) |
运算符 +(用于加法运算,操作两个 fixed_point 数) 更多... | |
template<typename Rep1 , Radix Rad1> | |
CUDF_HOST_DEVICE friend fixed_point< Rep1, Rad1 > | operator- (fixed_point< Rep1, Rad1 > const &lhs, fixed_point< Rep1, Rad1 > const &rhs) |
运算符 -(用于减法运算,操作两个 fixed_point 数) 更多... | |
template<typename Rep1 , Radix Rad1> | |
CUDF_HOST_DEVICE friend fixed_point< Rep1, Rad1 > | operator* (fixed_point< Rep1, Rad1 > const &lhs, fixed_point< Rep1, Rad1 > const &rhs) |
运算符 *(用于乘法运算,操作两个 fixed_point 数) 更多... | |
template<typename Rep1 , Radix Rad1> | |
CUDF_HOST_DEVICE friend fixed_point< Rep1, Rad1 > | operator/ (fixed_point< Rep1, Rad1 > const &lhs, fixed_point< Rep1, Rad1 > const &rhs) |
运算符 /(用于除法运算,操作两个 fixed_point 数) 更多... | |
template<typename Rep1 , Radix Rad1> | |
CUDF_HOST_DEVICE friend fixed_point< Rep1, Rad1 > | operator% (fixed_point< Rep1, Rad1 > const &lhs, fixed_point< Rep1, Rad1 > const &rhs) |
运算符 %(用于计算两个 fixed_point 数的模运算) 更多... | |
template<typename Rep1 , Radix Rad1> | |
CUDF_HOST_DEVICE friend bool | operator== (fixed_point< Rep1, Rad1 > const &lhs, fixed_point< Rep1, Rad1 > const &rhs) |
运算符 ==(用于比较两个 fixed_point 数) 更多... | |
template<typename Rep1 , Radix Rad1> | |
CUDF_HOST_DEVICE friend bool | operator!= (fixed_point< Rep1, Rad1 > const &lhs, fixed_point< Rep1, Rad1 > const &rhs) |
运算符 !=(用于比较两个 fixed_point 数) 更多... | |
template<typename Rep1 , Radix Rad1> | |
CUDF_HOST_DEVICE friend bool | operator<= (fixed_point< Rep1, Rad1 > const &lhs, fixed_point< Rep1, Rad1 > const &rhs) |
运算符 <=(用于比较两个 fixed_point 数) 更多... | |
template<typename Rep1 , Radix Rad1> | |
CUDF_HOST_DEVICE friend bool | operator>= (fixed_point< Rep1, Rad1 > const &lhs, fixed_point< Rep1, Rad1 > const &rhs) |
运算符 >=(用于比较两个 fixed_point 数) 更多... | |
template<typename Rep1 , Radix Rad1> | |
CUDF_HOST_DEVICE friend bool | operator< (fixed_point< Rep1, Rad1 > const &lhs, fixed_point< Rep1, Rad1 > const &rhs) |
运算符 <(用于比较两个 fixed_point 数) 更多... | |
template<typename Rep1 , Radix Rad1> | |
CUDF_HOST_DEVICE friend bool | operator> (fixed_point< Rep1, Rad1 > const &lhs, fixed_point< Rep1, Rad1 > const &rhs) |
运算符 >(用于比较两个 fixed_point 数) 更多... | |
表示具有固定精度值的类型。
目前,仅支持二进制和十进制 fixed_point
数。二进制运算只能与其他 fixed_point
数一起执行
Rep | 表示类型(可以是 int32_t 或 int64_t ) |
Rad | 基数(可以是 Radix::BASE_2 或 Radix::BASE_10 ) |
定义位于文件 fixed_point.hpp 的第 226 行。
|
内联显式编译时常量表达式 |
此构造函数将执行移位以适当存储值(从整数类型转换)
T | 构造时使用的整数类型 |
value | 用于构造的值 |
scale | 应用于基数 (Rad) 以执行移位的指数 |
定义位于文件 fixed_point.hpp 的第 245 行。
|
内联显式编译时常量表达式 |
|
内联 |
|
内联显式编译时常量表达式 |
|
内联 |
将 fixed_point
数转换为 scaled_integer
scaled_integer
数的 fixed_point
表示定义位于文件 fixed_point.hpp 的第 302 行。
|
内联显式编译时常量表达式 |
显式转换运算符,用于转换为整数类型。
U | 显式转换的目标整数类型 |
fixed_point
数(即人类可读格式)定义位于文件 fixed_point.hpp 的第 288 行。
|
内联 |
运算符 *=
Rep1 | 操作数 rhs 的表示类型 |
Rad1 | 操作数 rhs 的基数类型 |
rhs | 与 this 相乘的数 |
定义位于文件 fixed_point.hpp 的第 355 行。
|
内联 |
|
内联 |
运算符 +=
Rep1 | 操作数 rhs 的表示类型 |
Rad1 | 操作数 rhs 的基数类型 |
rhs | 添加到 this 的数 |
定义位于文件 fixed_point.hpp 的第 340 行。
|
内联 |
运算符 -=
Rep1 | 操作数 rhs 的表示类型 |
Rad1 | 操作数 rhs 的基数类型 |
rhs | 从 this 减去的数 |
定义位于文件 fixed_point.hpp 的第 370 行。
|
内联 |
运算符 /=
Rep1 | 操作数 rhs 的表示类型 |
Rad1 | 操作数 rhs 的基数类型 |
rhs | 被 this 除的数 |
定义位于文件 fixed_point.hpp 的第 385 行。
|
内联 |
创建具有新 scale
的 fixed_point
数的方法
返回的 fixed_point
数将具有与 this
相同的值、底层表示和基数,唯一改变的是比例。
scale | 返回的 fixed_point 数的 scale |
scale
的 fixed_point
数定义位于文件 fixed_point.hpp 的第 594 行。
|
内联 |
|
内联 |
|
友元 |
运算符 !=(用于比较两个 fixed_point
数)
如果 _scale
相等,则比较 _value
。如果 _scale
不相等,则将具有较大 _scale
的数移位到较小的 _scale
,然后比较 _value
。
Rep1 | 操作数 lhs 和 rhs 的表示类型 |
Rad1 | 操作数 lhs 和 rhs 的基数类型 |
lhs | 左侧操作数 |
rhs | 右侧操作数 |
lhs
和 rhs
不相等则为 true,否则为 false定义位于文件 fixed_point.hpp 的第 762 行。
|
友元 |
运算符 %(用于计算两个 fixed_point
数的模运算)
如果 _scale
相等,则直接计算模数。如果 _scale
不相等,则将具有较大 _scale
的数移位到较小的 _scale
,然后计算模数。
Rep1 | 操作数 lhs 和 rhs 的表示类型 |
Rad1 | 操作数 lhs 和 rhs 的基数类型 |
lhs | 左侧操作数 |
rhs | 右侧操作数 |
fixed_point
数定义位于文件 fixed_point.hpp 的第 807 行。
|
友元 |
运算符 *(用于乘法运算,操作两个 fixed_point
数)
_scale
相加,_value
相乘。
Rep1 | 操作数 lhs 和 rhs 的表示类型 |
Rad1 | 操作数 lhs 和 rhs 的基数类型 |
lhs | 左侧操作数 |
rhs | 右侧操作数 |
fixed_point
乘积定义位于文件 fixed_point.hpp 的第 723 行。
|
友元 |
运算符 +(用于加法运算,操作两个 fixed_point
数)
如果 _scale
相等,则 _value
相加。如果 _scale
不相等,则将具有较大 _scale
的数移位到较小的 _scale
,然后将 _value
相加。
Rep1 | 操作数 lhs 和 rhs 的表示类型 |
Rad1 | 操作数 lhs 和 rhs 的基数类型 |
lhs | 左侧操作数 |
rhs | 右侧操作数 |
fixed_point
和定义位于文件 fixed_point.hpp 的第 687 行。
|
友元 |
运算符 -(用于减法运算,操作两个 fixed_point
数)
如果 _scale
相等,则 _value
相减。如果 _scale
不相等,则将具有较大 _scale
的数移位到较小的 _scale
,然后将 _value
相减。
Rep1 | 操作数 lhs 和 rhs 的表示类型 |
Rad1 | 操作数 lhs 和 rhs 的基数类型 |
lhs | 左侧操作数 |
rhs | 右侧操作数 |
fixed_point
差定义位于文件 fixed_point.hpp 的第 705 行。
|
友元 |
运算符 /(用于除法运算,操作两个 fixed_point
数)
_scale
相减,_value
相除。
Rep1 | 操作数 lhs 和 rhs 的表示类型 |
Rad1 | 操作数 lhs 和 rhs 的基数类型 |
lhs | 左侧操作数 |
rhs | 右侧操作数 |
fixed_point
商定义位于文件 fixed_point.hpp 的第 738 行。
|
友元 |
运算符 <(用于比较两个 fixed_point
数)
如果 _scale
相等,则比较 _value
。如果 _scale
不相等,则将具有较大 _scale
的数移位到较小的 _scale
,然后比较 _value
。
Rep1 | 操作数 lhs 和 rhs 的表示类型 |
Rad1 | 操作数 lhs 和 rhs 的基数类型 |
lhs | 左侧操作数 |
rhs | 右侧操作数 |
lhs
小于 rhs
则为 true,否则为 false定义位于文件 fixed_point.hpp 的第 789 行。
|
友元 |
运算符 <=(用于比较两个 fixed_point
数)
如果 _scale
相等,则比较 _value
。如果 _scale
不相等,则将具有较大 _scale
的数移位到较小的 _scale
,然后比较 _value
。
Rep1 | 操作数 lhs 和 rhs 的表示类型 |
Rad1 | 操作数 lhs 和 rhs 的基数类型 |
lhs | 左侧操作数 |
rhs | 右侧操作数 |
lhs
小于或等于 rhs
则为 true,否则为 false定义位于文件 fixed_point.hpp 的第 771 行。
|
友元 |
运算符 ==(用于比较两个 fixed_point
数)
如果 _scale
相等,则比较 _value
。如果 _scale
不相等,则将具有较大 _scale
的数移位到较小的 _scale
,然后比较 _value
。
Rep1 | 操作数 lhs 和 rhs 的表示类型 |
Rad1 | 操作数 lhs 和 rhs 的基数类型 |
lhs | 左侧操作数 |
rhs | 右侧操作数 |
lhs
和 rhs
相等则为 true,否则为 false定义位于文件 fixed_point.hpp 的第 753 行。
|
友元 |
运算符 >(用于比较两个 fixed_point
数)
如果 _scale
相等,则比较 _value
。如果 _scale
不相等,则将具有较大 _scale
的数移位到较小的 _scale
,然后比较 _value
。
Rep1 | 操作数 lhs 和 rhs 的表示类型 |
Rad1 | 操作数 lhs 和 rhs 的基数类型 |
lhs | 左侧操作数 |
rhs | 右侧操作数 |
lhs
大于 rhs
则为 true,否则为 false定义位于文件 fixed_point.hpp 的第 798 行。
|
友元 |
运算符 >=(用于比较两个 fixed_point
数)
如果 _scale
相等,则比较 _value
。如果 _scale
不相等,则将具有较大 _scale
的数移位到较小的 _scale
,然后比较 _value
。
Rep1 | 操作数 lhs 和 rhs 的表示类型 |
Rad1 | 操作数 lhs 和 rhs 的基数类型 |
lhs | 左侧操作数 |
rhs | 右侧操作数 |
lhs
大于或等于 rhs
则为 true,否则为 false定义位于文件 fixed_point.hpp 的第 780 行。