公共类型 | 公共成员函数 | 静态公共属性 | 友元 | 所有成员列表
numeric::fixed_point< Rep, Rad > 类模板参考

表示具有固定精度值的类型。 更多...

#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
 创建具有新 scalefixed_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 数) 更多...
 

详细描述

template<typename Rep, Radix Rad>
class numeric::fixed_point< Rep, Rad >

表示具有固定精度值的类型。

目前,仅支持二进制和十进制 fixed_point 数。二进制运算只能与其他 fixed_point 数一起执行

模板参数
Rep表示类型(可以是 int32_tint64_t
Rad基数(可以是 Radix::BASE_2Radix::BASE_10

定义位于文件 fixed_point.hpp 的第 226 行。

构造函数和析构函数文档

◆ fixed_point() [1/3]

template<typename Rep , Radix Rad>
template<typename T , typename cuda::std::enable_if_t< cuda::std::is_integral_v< T > &&is_supported_representation_type< Rep >()> * = nullptr>
CUDF_HOST_DEVICE numeric::fixed_point< Rep, Rad >::fixed_point ( T const &  value,
scale_type const &  scale 
)
内联显式编译时常量表达式

此构造函数将执行移位以适当存储值(从整数类型转换)

模板参数
T构造时使用的整数类型
参数
value用于构造的值
scale应用于基数 (Rad) 以执行移位的指数

定义位于文件 fixed_point.hpp 的第 245 行。

◆ fixed_point() [2/3]

template<typename Rep , Radix Rad>
CUDF_HOST_DEVICE numeric::fixed_point< Rep, Rad >::fixed_point ( scaled_integer< Rep >  s)
内联显式编译时常量表达式

此构造函数不会执行移位(假定值已移位)

参数
s包含比例和已移位值的 scaled_integer

定义位于文件 fixed_point.hpp 的第 257 行。

◆ fixed_point() [3/3]

template<typename Rep , Radix Rad>
template<typename T , typename cuda::std::enable_if_t< cuda::std::is_integral_v< T >> * = nullptr>
CUDF_HOST_DEVICE numeric::fixed_point< Rep, Rad >::fixed_point ( T const &  value)
内联

“无比例”构造函数,使用指定值和零比例构造 fixed_point

模板参数
T构造时使用的值类型
参数
value用于构造的值

定义位于文件 fixed_point.hpp 的第 270 行。

成员函数文档

◆ operator bool()

template<typename Rep , Radix Rad>
constexpr CUDF_HOST_DEVICE numeric::fixed_point< Rep, Rad >::operator bool ( ) const
内联显式编译时常量表达式

显式转换为 bool 的运算符

返回值
fixed_point 值转换为布尔值(零为 false,非零为 true

定义位于文件 fixed_point.hpp 的第 326 行。

◆ operator scaled_integer< Rep >()

template<typename Rep , Radix Rad>
CUDF_HOST_DEVICE numeric::fixed_point< Rep, Rad >::operator scaled_integer< Rep > ( ) const
内联

fixed_point 数转换为 scaled_integer

返回值
scaled_integer 数的 fixed_point 表示

定义位于文件 fixed_point.hpp 的第 302 行。

◆ operator U()

template<typename Rep , Radix Rad>
template<typename U , typename cuda::std::enable_if_t< cuda::std::is_integral_v< U >> * = nullptr>
constexpr CUDF_HOST_DEVICE numeric::fixed_point< Rep, Rad >::operator U ( ) const
内联显式编译时常量表达式

显式转换运算符,用于转换为整数类型。

模板参数
U显式转换的目标整数类型
返回值
基数为 10 的 fixed_point 数(即人类可读格式)

定义位于文件 fixed_point.hpp 的第 288 行。

◆ operator*=()

template<typename Rep , Radix Rad>
template<typename Rep1 , Radix Rad1>
CUDF_HOST_DEVICE fixed_point<Rep1, Rad1>& numeric::fixed_point< Rep, Rad >::operator*= ( fixed_point< Rep1, Rad1 > const &  rhs)
内联

运算符 *=

模板参数
Rep1操作数 rhs 的表示类型
Rad1操作数 rhs 的基数类型
参数
rhsthis 相乘的数
返回值
乘积

定义位于文件 fixed_point.hpp 的第 355 行。

◆ operator++()

template<typename Rep , Radix Rad>
CUDF_HOST_DEVICE fixed_point<Rep, Rad>& numeric::fixed_point< Rep, Rad >::operator++ ( )
内联

运算符 ++(后置增量)

返回值
增量结果

定义位于文件 fixed_point.hpp 的第 396 行。

◆ operator+=()

template<typename Rep , Radix Rad>
template<typename Rep1 , Radix Rad1>
CUDF_HOST_DEVICE fixed_point<Rep1, Rad1>& numeric::fixed_point< Rep, Rad >::operator+= ( fixed_point< Rep1, Rad1 > const &  rhs)
内联

运算符 +=

模板参数
Rep1操作数 rhs 的表示类型
Rad1操作数 rhs 的基数类型
参数
rhs添加到 this 的数
返回值

定义位于文件 fixed_point.hpp 的第 340 行。

◆ operator-=()

template<typename Rep , Radix Rad>
template<typename Rep1 , Radix Rad1>
CUDF_HOST_DEVICE fixed_point<Rep1, Rad1>& numeric::fixed_point< Rep, Rad >::operator-= ( fixed_point< Rep1, Rad1 > const &  rhs)
内联

运算符 -=

模板参数
Rep1操作数 rhs 的表示类型
Rad1操作数 rhs 的基数类型
参数
rhsthis 减去的数
返回值

定义位于文件 fixed_point.hpp 的第 370 行。

◆ operator/=()

template<typename Rep , Radix Rad>
template<typename Rep1 , Radix Rad1>
CUDF_HOST_DEVICE fixed_point<Rep1, Rad1>& numeric::fixed_point< Rep, Rad >::operator/= ( fixed_point< Rep1, Rad1 > const &  rhs)
内联

运算符 /=

模板参数
Rep1操作数 rhs 的表示类型
Rad1操作数 rhs 的基数类型
参数
rhsthis 除的数
返回值

定义位于文件 fixed_point.hpp 的第 385 行。

◆ rescaled()

template<typename Rep , Radix Rad>
CUDF_HOST_DEVICE fixed_point<Rep, Rad> numeric::fixed_point< Rep, Rad >::rescaled ( scale_type  scale) const
内联

创建具有新 scalefixed_point 数的方法

返回的 fixed_point 数将具有与 this 相同的值、底层表示和基数,唯一改变的是比例。

参数
scale返回的 fixed_point 数的 scale
返回值
具有新 scalefixed_point

定义位于文件 fixed_point.hpp 的第 594 行。

◆ scale()

template<typename Rep , Radix Rad>
CUDF_HOST_DEVICE scale_type numeric::fixed_point< Rep, Rad >::scale ( ) const
内联

返回 fixed_point 数比例的方法。

返回值
fixed_point 数的比例

定义位于文件 fixed_point.hpp 的第 319 行。

◆ value()

template<typename Rep , Radix Rad>
CUDF_HOST_DEVICE rep numeric::fixed_point< Rep, Rad >::value ( ) const
内联

返回 fixed_point 数底层值的方法。

返回值
fixed_point 数的底层值

定义位于文件 fixed_point.hpp 的第 312 行。

友元和相关函数文档

◆ operator!=

template<typename Rep , Radix Rad>
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 数)

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

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

定义位于文件 fixed_point.hpp 的第 762 行。

◆ operator%

template<typename Rep , Radix 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 数的模运算)

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

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

定义位于文件 fixed_point.hpp 的第 807 行。

◆ operator*

template<typename Rep , Radix 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 数)

_scale 相加,_value 相乘。

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

定义位于文件 fixed_point.hpp 的第 723 行。

◆ operator+

template<typename Rep , Radix 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 数)

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

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

定义位于文件 fixed_point.hpp 的第 687 行。

◆ operator-

template<typename Rep , Radix 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 数)

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

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

定义位于文件 fixed_point.hpp 的第 705 行。

◆ operator/

template<typename Rep , Radix 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 数)

_scale 相减,_value 相除。

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

定义位于文件 fixed_point.hpp 的第 738 行。

◆ operator<

template<typename Rep , Radix Rad>
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 数)

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

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

定义位于文件 fixed_point.hpp 的第 789 行。

◆ operator<=

template<typename Rep , Radix Rad>
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 数)

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

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

定义位于文件 fixed_point.hpp 的第 771 行。

◆ operator==

template<typename Rep , Radix Rad>
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 数)

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

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

定义位于文件 fixed_point.hpp 的第 753 行。

◆ operator>

template<typename Rep , Radix Rad>
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 数)

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

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

定义位于文件 fixed_point.hpp 的第 798 行。

◆ operator>=

template<typename Rep , Radix Rad>
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 数)

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

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

定义位于文件 fixed_point.hpp 的第 780 行。


本类文档生成自以下文件