文件 | | 类型定义 | 枚举 | 函数
定点

文件

文件  fixed_point.hpp
 定点数据类型的类定义。
 
文件  fixed_point.hpp
 定点数据类型的类定义。
 

结构体  numeric::scaled_integer< Rep, >
 用于构造 fixed_point 当值已被移位时使用的辅助结构体。 更多...
 
类  numeric::fixed_point< Rep, Rad >
 表示具有固定精度量的数字的类型。 更多...
 

类型定义

使用 numeric::decimal32 = fixed_point< int32_t, Radix::BASE_10 >
 32位十进制定点
 
使用 numeric::decimal64 = fixed_point< int64_t, Radix::BASE_10 >
 64位十进制定点
 
使用 numeric::decimal128 = fixed_point< __int128_t, Radix::BASE_10 >
 128位十进制定点
 

枚举

枚举  numeric::scale_type : int32_t
 fixed_point 的刻度类型。
 
枚举类  numeric::Radix : int32_t { BASE_2 = 2 , BASE_10 = 10 }
 用于构造 fixed_point 的范围枚举器 更多...
 

函数

template<typename T >
constexpr CUDF_HOST_DEVICE auto numeric::is_supported_representation_type ()
 如果表示类型受 fixed_point 支持,则返回 true 更多...
 
template<typename Rep , typename T >
CUDF_HOST_DEVICE auto numeric::addition_overflow (T lhs, T rhs)
 用于识别加法时整数溢出的函数。 更多...
 
template<typename Rep , typename T >
CUDF_HOST_DEVICE auto numeric::subtraction_overflow (T lhs, T rhs)
 用于识别减法时整数溢出的函数。 更多...
 
template<typename Rep , typename T >
CUDF_HOST_DEVICE auto numeric::division_overflow (T lhs, T rhs)
 用于识别除法时整数溢出的函数。 更多...
 
template<typename Rep , typename T >
CUDF_HOST_DEVICE auto numeric::multiplication_overflow (T lhs, T 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 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)
 

详细描述

枚举类型文档

◆ 基数

enum numeric::Radix : int32_t
强类型

用于构造 fixed_point 的范围枚举器

示例

using decimal32 = fixed_point<int32_t, Radix::BASE_10>;
using binary64 = fixed_point<int64_t, Radix::BASE_2>;
fixed_point< int32_t, Radix::BASE_10 > decimal32
32位十进制定点

定义于文件 fixed_point.hpp54 行。

函数文档

◆ addition_overflow()

template<typename Rep , typename T >
CUDF_HOST_DEVICE auto numeric::addition_overflow ( lhs,
rhs 
)
inline

用于识别加法时整数溢出的函数。

模板参数
Rep要检查溢出的整数类型
Tlhs 和 rhs 的类型(确保它们是相同的类型)
参数
lhs加法的左操作数
rhs加法的右操作数
返回值
如果加法导致溢出则为 true,否则为 false

定义于文件 fixed_point.hpp632 行。

◆ division_overflow()

template<typename Rep , typename T >
CUDF_HOST_DEVICE auto numeric::division_overflow ( lhs,
rhs 
)
inline

用于识别除法时整数溢出的函数。

模板参数
Rep要检查溢出的整数类型
Tlhs 和 rhs 的类型(确保它们是相同的类型)
参数
lhs除法的左操作数
rhs除法的右操作数
返回值
如果除法导致溢出则为 true,否则为 false

定义于文件 fixed_point.hpp662 行。

◆ is_supported_representation_type()

template<typename T >
constexpr CUDF_HOST_DEVICE auto numeric::is_supported_representation_type ( )
inlineconstexpr

如果表示类型受 fixed_point 支持,则返回 true

模板参数
T表示类型
返回值
如果该类型受 fixed_point 实现支持,则为 true

定义于文件 fixed_point.hpp63 行。

◆ multiplication_overflow()

template<typename Rep , typename T >
CUDF_HOST_DEVICE auto numeric::multiplication_overflow ( lhs,
rhs 
)
inline

用于识别乘法时整数溢出的函数。

模板参数
Rep要检查溢出的整数类型
Tlhs 和 rhs 的类型(确保它们是相同的类型)
参数
lhs乘法的左操作数
rhs乘法的右操作数
返回值
如果乘法导致溢出则为 true,否则为 false

定义于文件 fixed_point.hpp676 行。

◆ operator!=()

template<typename Rep1 , Radix Rad1>
CUDF_HOST_DEVICE bool numeric::operator!= ( fixed_point< Rep1, Rad1 > const &  lhs,
fixed_point< Rep1, Rad1 > const &  rhs 
)
inline

如果 _scale 相等,则比较 _value。如果 _scale 不相等,则将具有较大 _scale 的数字移位到较小的 _scale,然后比较 _value

模板参数
Rep1操作数 lhsrhs 的表示类型
Rad1操作数 lhsrhs 的基数类型
参数
lhs左操作数
rhs右操作数
返回值
如果 lhsrhs 不相等则为 true,否则为 false

定义于文件 fixed_point.hpp762 行。

◆ operator%()

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 
)
inline

如果 _scale 相等,直接计算模数。如果 _scale 不相等,则将具有较大 _scale 的数字移位到较小的 _scale,然后计算模数。

模板参数
Rep1操作数 lhsrhs 的表示类型
Rad1操作数 lhsrhs 的基数类型
参数
lhs左操作数
rhs右操作数
返回值
结果的 fixed_point 数字

定义于文件 fixed_point.hpp807 行。

◆ operator*()

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 
)
inline

_scale 相加,并将 _value 相乘。

模板参数
Rep1操作数 lhsrhs 的表示类型
Rad1操作数 lhsrhs 的基数类型
参数
lhs左操作数
rhs右操作数
返回值
结果的 fixed_point 乘积

定义于文件 fixed_point.hpp723 行。

◆ operator+()

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 
)
inline

如果 _scale 相等,则将 _value 相加。如果 _scale 不相等,则将具有较大 _scale 的数字移位到较小的 _scale,然后将 _value 相加。

模板参数
Rep1操作数 lhsrhs 的表示类型
Rad1操作数 lhsrhs 的基数类型
参数
lhs左操作数
rhs右操作数
返回值
结果的 fixed_point

定义于文件 fixed_point.hpp687 行。

◆ operator-()

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 
)
inline

如果 _scale 相等,则将 _value 相减。如果 _scale 不相等,则将具有较大 _scale 的数字移位到较小的 _scale,然后将 _value 相减。

模板参数
Rep1操作数 lhsrhs 的表示类型
Rad1操作数 lhsrhs 的基数类型
参数
lhs左操作数
rhs右操作数
返回值
结果的 fixed_point

定义于文件 fixed_point.hpp705 行。

◆ operator/()

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 
)
inline

_scale 相减,并将 _value 相除。

模板参数
Rep1操作数 lhsrhs 的表示类型
Rad1操作数 lhsrhs 的基数类型
参数
lhs左操作数
rhs右操作数
返回值
结果的 fixed_point

定义于文件 fixed_point.hpp738 行。

◆ operator<()

template<typename Rep1 , Radix Rad1>
CUDF_HOST_DEVICE bool numeric::operator< ( fixed_point< Rep1, Rad1 > const &  lhs,
fixed_point< Rep1, Rad1 > const &  rhs 
)
inline

如果 _scale 相等,则比较 _value。如果 _scale 不相等,则将具有较大 _scale 的数字移位到较小的 _scale,然后比较 _value

模板参数
Rep1操作数 lhsrhs 的表示类型
Rad1操作数 lhsrhs 的基数类型
参数
lhs左操作数
rhs右操作数
返回值
如果 lhs 小于 rhs 则为 true,否则为 false

定义于文件 fixed_point.hpp789 行。

◆ operator<=()

template<typename Rep1 , Radix Rad1>
CUDF_HOST_DEVICE bool numeric::operator<= ( fixed_point< Rep1, Rad1 > const &  lhs,
fixed_point< Rep1, Rad1 > const &  rhs 
)
inline

如果 _scale 相等,则比较 _value。如果 _scale 不相等,则将具有较大 _scale 的数字移位到较小的 _scale,然后比较 _value

模板参数
Rep1操作数 lhsrhs 的表示类型
Rad1操作数 lhsrhs 的基数类型
参数
lhs左操作数
rhs右操作数
返回值
如果 lhs 小于或等于 rhs 则为 true,否则为 false

定义于文件 fixed_point.hpp771 行。

◆ operator==()

template<typename Rep1 , Radix Rad1>
CUDF_HOST_DEVICE bool numeric::operator== ( fixed_point< Rep1, Rad1 > const &  lhs,
fixed_point< Rep1, Rad1 > const &  rhs 
)
inline

如果 _scale 相等,则比较 _value。如果 _scale 不相等,则将具有较大 _scale 的数字移位到较小的 _scale,然后比较 _value

模板参数
Rep1操作数 lhsrhs 的表示类型
Rad1操作数 lhsrhs 的基数类型
参数
lhs左操作数
rhs右操作数
返回值
如果 lhsrhs 相等则为 true,否则为 false

定义于文件 fixed_point.hpp753 行。

◆ operator>()

template<typename Rep1 , Radix Rad1>
CUDF_HOST_DEVICE bool numeric::operator> ( fixed_point< Rep1, Rad1 > const &  lhs,
fixed_point< Rep1, Rad1 > const &  rhs 
)
inline

如果 _scale 相等,则比较 _value。如果 _scale 不相等,则将具有较大 _scale 的数字移位到较小的 _scale,然后比较 _value

模板参数
Rep1操作数 lhsrhs 的表示类型
Rad1操作数 lhsrhs 的基数类型
参数
lhs左操作数
rhs右操作数
返回值
如果 lhs 大于 rhs 则为 true,否则为 false

定义于文件 fixed_point.hpp798 行。

◆ operator>=()

template<typename Rep1 , Radix Rad1>
CUDF_HOST_DEVICE bool numeric::operator>= ( fixed_point< Rep1, Rad1 > const &  lhs,
fixed_point< Rep1, Rad1 > const &  rhs 
)
inline

如果 _scale 相等,则比较 _value。如果 _scale 不相等,则将具有较大 _scale 的数字移位到较小的 _scale,然后比较 _value

模板参数
Rep1操作数 lhsrhs 的表示类型
Rad1操作数 lhsrhs 的基数类型
参数
lhs左操作数
rhs右操作数
返回值
如果 lhs 大于或等于 rhs 则为 true,否则为 false

定义于文件 fixed_point.hpp780 行。

◆ subtraction_overflow()

template<typename Rep , typename T >
CUDF_HOST_DEVICE auto numeric::subtraction_overflow ( lhs,
rhs 
)
inline

用于识别减法时整数溢出的函数。

模板参数
Rep要检查溢出的整数类型
Tlhs 和 rhs 的类型(确保它们是相同的类型)
参数
lhs减法的左操作数
rhs减法的右操作数
返回值
如果减法导致溢出则为 true,否则为 false

定义于文件 fixed_point.hpp647 行。