YSTest  PreAlpha_b400_20130424
The YSLib Test Project
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
ystdex::fixed_point< _tBase, _vInt, _vFrac > 模板类 参考

通用定点数。 更多...

#include <rational.hpp>

类 ystdex::fixed_point< _tBase, _vInt, _vFrac > 继承关系图:
ystdex::fixed_point< _tBase, _vInt, _vFrac > 的协作图:

Public 类型

typedef _tBase base_type
 

Public 成员函数

 fixed_point () ynoexcept
 无参数构造。
 
template<typename _tInt >
 fixed_point (_tInt val, typename std::enable_if< std::is_integral< _tInt >::value, int >::type=0) ynoexcept
 
template<typename _tFloat >
 fixed_point (_tFloat val, typename std::enable_if< std::is_floating_point< _tFloat >::value, int >::type=0) ynoexcept
 
 fixed_point (const fixed_point &)=default
 
template<size_t _vOtherInt, size_t _vOtherFrac>
 fixed_point (const fixed_point< base_type, _vOtherInt, _vOtherFrac > &f, typename std::enable_if<(_vOtherInt< int_bit_n), int >::type=0) ynoexcept
 
template<size_t _vOtherInt, size_t _vOtherFrac>
 fixed_point (const fixed_point< base_type, _vOtherInt, _vOtherFrac > &f, typename std::enable_if<(int_bit_n< _vOtherInt), int >::type=0) ynoexcept
 
bool operator< (const fixed_point &f) const ynoexcept
 
bool operator== (const fixed_point &f) const ynoexcept
 
bool operator! () const ynoexcept
 
fixed_point operator- () const ynoexcept
 
fixed_pointoperator++ () ynoexcept
 
fixed_pointoperator-- () ynoexcept
 
fixed_pointoperator+= (const fixed_point &f) ynoexcept
 
fixed_pointoperator-= (const fixed_point &f) ynoexcept
 
fixed_pointoperator*= (const fixed_point &f) ynoexcept
 
fixed_pointoperator/= (const fixed_point &f) ynoexcept
 
fixed_pointoperator>>= (size_t s) ynoexcept
 
fixed_pointoperator<<= (size_t s) ynoexcept
 
template<typename _type >
 operator _type () const
 

静态 Public 成员函数

static base_type base_element () ynoexcept
 base_type 表达的单位元。
 
static fixed_point identity () ynoexcept
 取单位元。
 

静态 Public 属性

static const size_t int_bit_n = _vInt
 整数部分二进制位数。
 
static const size_t frac_bit_n = _vFrac
 小数部分二进制位数。
 
static const size_t digit_bit_n = int_bit_n + frac_bit_n
 非符号位的二进制位数。
 

Private 类型

typedef empty_base< fixed_pointinternal_construct_tag
 内部构造类型( private 构造重载用)。
 

Private 成员函数

 fixed_point (base_type v, internal_construct_tag) ynoexcept
 
template<typename _type >
std::enable_if
< std::is_integral< _type >
::value, _type >::type 
cast () const
 
template<typename _type >
std::enable_if
< std::is_floating_point
< _type >::value, _type >
::type 
cast () const
 

Private 属性

base_type value
 

友元

template<typename _OtherBase , size_t _vOtherInt, size_t _vOtherFrac>
class fixed_point
 
class std::numeric_limits< fixed_point< _tBase, _vInt, _vFrac > >
 
fixed_point fabs (fixed_point x)
 
fixed_point ceil (fixed_point x)
 
fixed_point floor (fixed_point x)
 
fixed_point round (fixed_point x)
 

详细描述

template<typename _tBase = std::int32_t, size_t _vInt = std::numeric_limits<_tBase>::digits - 6U, size_t _vFrac = std::numeric_limits<_tBase>::digits - _vInt>
class ystdex::fixed_point< _tBase, _vInt, _vFrac >

通用定点数。

基于整数算术实现的确定有限精度二进制定点小数类型。可用于替换内建的浮点数类型。 是否有符号同基本整数类型参数。若有符号,则最高有效位为符号位。 逻辑布局: [符号位]|整数部分|小数部分 。各个部分的内部为补码表示。

模板参数
_tBase基本整数类型。
_vInt整数部分(若有符号则不包括符号位,下同)二进制位数。
_vFrac分数部分二进制位数。
注解
默认保留 6 位二进制小数。
部分实现参考: http://www.codeproject.com/KB/cpp/fp_math.aspx
警告
基本整数类型需要具有补码表示。
非虚析构。
算术运算可能溢出。
自从
build 260

在文件 rational.hpp100 行定义.

成员类型定义说明

template<typename _tBase = std::int32_t, size_t _vInt = std::numeric_limits<_tBase>::digits - 6U, size_t _vFrac = std::numeric_limits<_tBase>::digits - _vInt>
typedef _tBase ystdex::fixed_point< _tBase, _vInt, _vFrac >::base_type

在文件 rational.hpp116 行定义.

template<typename _tBase = std::int32_t, size_t _vInt = std::numeric_limits<_tBase>::digits - 6U, size_t _vFrac = std::numeric_limits<_tBase>::digits - _vInt>
typedef empty_base<fixed_point> ystdex::fixed_point< _tBase, _vInt, _vFrac >::internal_construct_tag
private

内部构造类型( private 构造重载用)。

在文件 rational.hpp127 行定义.

构造及析构函数说明

template<typename _tBase = std::int32_t, size_t _vInt = std::numeric_limits<_tBase>::digits - 6U, size_t _vFrac = std::numeric_limits<_tBase>::digits - _vInt>
ystdex::fixed_point< _tBase, _vInt, _vFrac >::fixed_point ( )
inline

无参数构造。

警告
基本整数类型成员未被初始化,具有未决定值 ,使用可能造成未定义行为。

在文件 rational.hpp137 行定义.

template<typename _tBase = std::int32_t, size_t _vInt = std::numeric_limits<_tBase>::digits - 6U, size_t _vFrac = std::numeric_limits<_tBase>::digits - _vInt>
ystdex::fixed_point< _tBase, _vInt, _vFrac >::fixed_point ( base_type  v,
internal_construct_tag   
)
inlineprivate

在文件 rational.hpp141 行定义.

template<typename _tBase = std::int32_t, size_t _vInt = std::numeric_limits<_tBase>::digits - 6U, size_t _vFrac = std::numeric_limits<_tBase>::digits - _vInt>
template<typename _tInt >
ystdex::fixed_point< _tBase, _vInt, _vFrac >::fixed_point ( _tInt  val,
typename std::enable_if< std::is_integral< _tInt >::value, int >::type  = 0 
)
inline

在文件 rational.hpp147 行定义.

template<typename _tBase = std::int32_t, size_t _vInt = std::numeric_limits<_tBase>::digits - 6U, size_t _vFrac = std::numeric_limits<_tBase>::digits - _vInt>
template<typename _tFloat >
ystdex::fixed_point< _tBase, _vInt, _vFrac >::fixed_point ( _tFloat  val,
typename std::enable_if< std::is_floating_point< _tFloat >::value, int >::type  = 0 
)
inline

在文件 rational.hpp152 行定义.

template<typename _tBase = std::int32_t, size_t _vInt = std::numeric_limits<_tBase>::digits - 6U, size_t _vFrac = std::numeric_limits<_tBase>::digits - _vInt>
ystdex::fixed_point< _tBase, _vInt, _vFrac >::fixed_point ( const fixed_point< _tBase, _vInt, _vFrac > &  )
inlinedefault
template<typename _tBase = std::int32_t, size_t _vInt = std::numeric_limits<_tBase>::digits - 6U, size_t _vFrac = std::numeric_limits<_tBase>::digits - _vInt>
template<size_t _vOtherInt, size_t _vOtherFrac>
ystdex::fixed_point< _tBase, _vInt, _vFrac >::fixed_point ( const fixed_point< base_type, _vOtherInt, _vOtherFrac > &  f)
inline

在文件 rational.hpp161 行定义.

template<typename _tBase = std::int32_t, size_t _vInt = std::numeric_limits<_tBase>::digits - 6U, size_t _vFrac = std::numeric_limits<_tBase>::digits - _vInt>
template<size_t _vOtherInt, size_t _vOtherFrac>
ystdex::fixed_point< _tBase, _vInt, _vFrac >::fixed_point ( const fixed_point< base_type, _vOtherInt, _vOtherFrac > &  f)
inline

在文件 rational.hpp167 行定义.

成员函数说明

template<typename _tBase = std::int32_t, size_t _vInt = std::numeric_limits<_tBase>::digits - 6U, size_t _vFrac = std::numeric_limits<_tBase>::digits - _vInt>
static base_type ystdex::fixed_point< _tBase, _vInt, _vFrac >::base_element ( )
inlinestatic

base_type 表达的单位元。

取值等于 1 的元素,使用 base_type 表达。

在文件 rational.hpp284 行定义.

参考自 ystdex::fixed_point< u16, 9 >::operator+=() , 以及 ystdex::fixed_point< u16, 9 >::operator-=().

这是这个函数的调用关系图:

template<typename _tBase = std::int32_t, size_t _vInt = std::numeric_limits<_tBase>::digits - 6U, size_t _vFrac = std::numeric_limits<_tBase>::digits - _vInt>
template<typename _type >
std::enable_if<std::is_integral<_type>::value, _type>::type ystdex::fixed_point< _tBase, _vInt, _vFrac >::cast ( ) const
inlineprivate

在文件 rational.hpp265 行定义.

template<typename _tBase = std::int32_t, size_t _vInt = std::numeric_limits<_tBase>::digits - 6U, size_t _vFrac = std::numeric_limits<_tBase>::digits - _vInt>
template<typename _type >
std::enable_if<std::is_floating_point<_type>::value, _type>::type ystdex::fixed_point< _tBase, _vInt, _vFrac >::cast ( ) const
inlineprivate

在文件 rational.hpp272 行定义.

template<typename _tBase = std::int32_t, size_t _vInt = std::numeric_limits<_tBase>::digits - 6U, size_t _vFrac = std::numeric_limits<_tBase>::digits - _vInt>
static fixed_point ystdex::fixed_point< _tBase, _vInt, _vFrac >::identity ( )
inlinestatic

取单位元。

取值等于 1 的元素。

在文件 rational.hpp294 行定义.

template<typename _tBase = std::int32_t, size_t _vInt = std::numeric_limits<_tBase>::digits - 6U, size_t _vFrac = std::numeric_limits<_tBase>::digits - _vInt>
template<typename _type >
ystdex::fixed_point< _tBase, _vInt, _vFrac >::operator _type ( ) const
inline

在文件 rational.hpp256 行定义.

template<typename _tBase = std::int32_t, size_t _vInt = std::numeric_limits<_tBase>::digits - 6U, size_t _vFrac = std::numeric_limits<_tBase>::digits - _vInt>
bool ystdex::fixed_point< _tBase, _vInt, _vFrac >::operator! ( ) const
inline

在文件 rational.hpp183 行定义.

template<typename _tBase = std::int32_t, size_t _vInt = std::numeric_limits<_tBase>::digits - 6U, size_t _vFrac = std::numeric_limits<_tBase>::digits - _vInt>
fixed_point& ystdex::fixed_point< _tBase, _vInt, _vFrac >::operator*= ( const fixed_point< _tBase, _vInt, _vFrac > &  f)
inline

在文件 rational.hpp220 行定义.

template<typename _tBase = std::int32_t, size_t _vInt = std::numeric_limits<_tBase>::digits - 6U, size_t _vFrac = std::numeric_limits<_tBase>::digits - _vInt>
fixed_point& ystdex::fixed_point< _tBase, _vInt, _vFrac >::operator++ ( )
inline

在文件 rational.hpp196 行定义.

template<typename _tBase = std::int32_t, size_t _vInt = std::numeric_limits<_tBase>::digits - 6U, size_t _vFrac = std::numeric_limits<_tBase>::digits - _vInt>
fixed_point& ystdex::fixed_point< _tBase, _vInt, _vFrac >::operator+= ( const fixed_point< _tBase, _vInt, _vFrac > &  f)
inline

在文件 rational.hpp208 行定义.

template<typename _tBase = std::int32_t, size_t _vInt = std::numeric_limits<_tBase>::digits - 6U, size_t _vFrac = std::numeric_limits<_tBase>::digits - _vInt>
fixed_point ystdex::fixed_point< _tBase, _vInt, _vFrac >::operator- ( ) const
inline

在文件 rational.hpp188 行定义.

template<typename _tBase = std::int32_t, size_t _vInt = std::numeric_limits<_tBase>::digits - 6U, size_t _vFrac = std::numeric_limits<_tBase>::digits - _vInt>
fixed_point& ystdex::fixed_point< _tBase, _vInt, _vFrac >::operator-- ( )
inline

在文件 rational.hpp202 行定义.

template<typename _tBase = std::int32_t, size_t _vInt = std::numeric_limits<_tBase>::digits - 6U, size_t _vFrac = std::numeric_limits<_tBase>::digits - _vInt>
fixed_point& ystdex::fixed_point< _tBase, _vInt, _vFrac >::operator-= ( const fixed_point< _tBase, _vInt, _vFrac > &  f)
inline

在文件 rational.hpp214 行定义.

template<typename _tBase = std::int32_t, size_t _vInt = std::numeric_limits<_tBase>::digits - 6U, size_t _vFrac = std::numeric_limits<_tBase>::digits - _vInt>
fixed_point& ystdex::fixed_point< _tBase, _vInt, _vFrac >::operator/= ( const fixed_point< _tBase, _vInt, _vFrac > &  f)
inline

在文件 rational.hpp236 行定义.

template<typename _tBase = std::int32_t, size_t _vInt = std::numeric_limits<_tBase>::digits - 6U, size_t _vFrac = std::numeric_limits<_tBase>::digits - _vInt>
bool ystdex::fixed_point< _tBase, _vInt, _vFrac >::operator< ( const fixed_point< _tBase, _vInt, _vFrac > &  f) const
inline

在文件 rational.hpp173 行定义.

template<typename _tBase = std::int32_t, size_t _vInt = std::numeric_limits<_tBase>::digits - 6U, size_t _vFrac = std::numeric_limits<_tBase>::digits - _vInt>
fixed_point& ystdex::fixed_point< _tBase, _vInt, _vFrac >::operator<<= ( size_t  s)
inline

在文件 rational.hpp249 行定义.

template<typename _tBase = std::int32_t, size_t _vInt = std::numeric_limits<_tBase>::digits - 6U, size_t _vFrac = std::numeric_limits<_tBase>::digits - _vInt>
bool ystdex::fixed_point< _tBase, _vInt, _vFrac >::operator== ( const fixed_point< _tBase, _vInt, _vFrac > &  f) const
inline

在文件 rational.hpp178 行定义.

template<typename _tBase = std::int32_t, size_t _vInt = std::numeric_limits<_tBase>::digits - 6U, size_t _vFrac = std::numeric_limits<_tBase>::digits - _vInt>
fixed_point& ystdex::fixed_point< _tBase, _vInt, _vFrac >::operator>>= ( size_t  s)
inline

在文件 rational.hpp243 行定义.

友元及相关函数文档

template<typename _tBase = std::int32_t, size_t _vInt = std::numeric_limits<_tBase>::digits - 6U, size_t _vFrac = std::numeric_limits<_tBase>::digits - _vInt>
fixed_point ceil ( fixed_point< _tBase, _vInt, _vFrac >  x)
friend

在文件 rational.hpp305 行定义.

template<typename _tBase = std::int32_t, size_t _vInt = std::numeric_limits<_tBase>::digits - 6U, size_t _vFrac = std::numeric_limits<_tBase>::digits - _vInt>
fixed_point fabs ( fixed_point< _tBase, _vInt, _vFrac >  x)
friend

在文件 rational.hpp299 行定义.

template<typename _tBase = std::int32_t, size_t _vInt = std::numeric_limits<_tBase>::digits - 6U, size_t _vFrac = std::numeric_limits<_tBase>::digits - _vInt>
template<typename _OtherBase , size_t _vOtherInt, size_t _vOtherFrac>
friend class fixed_point
friend

在文件 rational.hpp105 行定义.

template<typename _tBase = std::int32_t, size_t _vInt = std::numeric_limits<_tBase>::digits - 6U, size_t _vFrac = std::numeric_limits<_tBase>::digits - _vInt>
fixed_point floor ( fixed_point< _tBase, _vInt, _vFrac >  x)
friend

在文件 rational.hpp312 行定义.

template<typename _tBase = std::int32_t, size_t _vInt = std::numeric_limits<_tBase>::digits - 6U, size_t _vFrac = std::numeric_limits<_tBase>::digits - _vInt>
fixed_point round ( fixed_point< _tBase, _vInt, _vFrac >  x)
friend

在文件 rational.hpp319 行定义.

template<typename _tBase = std::int32_t, size_t _vInt = std::numeric_limits<_tBase>::digits - 6U, size_t _vFrac = std::numeric_limits<_tBase>::digits - _vInt>
friend class std::numeric_limits< fixed_point< _tBase, _vInt, _vFrac > >
friend

在文件 rational.hpp113 行定义.

类成员变量说明

template<typename _tBase = std::int32_t, size_t _vInt = std::numeric_limits<_tBase>::digits - 6U, size_t _vFrac = std::numeric_limits<_tBase>::digits - _vInt>
const size_t ystdex::fixed_point< _tBase, _vInt, _vFrac >::digit_bit_n = int_bit_n + frac_bit_n
static

非符号位的二进制位数。

在文件 rational.hpp123 行定义.

template<typename _tBase = std::int32_t, size_t _vInt = std::numeric_limits<_tBase>::digits - 6U, size_t _vFrac = std::numeric_limits<_tBase>::digits - _vInt>
const size_t ystdex::fixed_point< _tBase, _vInt, _vFrac >::frac_bit_n = _vFrac
static

小数部分二进制位数。

在文件 rational.hpp121 行定义.

参考自 ystdex::fixed_point< u16, 9 >::base_element() , 以及 ystdex::fixed_point< u16, 9 >::operator/=().

template<typename _tBase = std::int32_t, size_t _vInt = std::numeric_limits<_tBase>::digits - 6U, size_t _vFrac = std::numeric_limits<_tBase>::digits - _vInt>
const size_t ystdex::fixed_point< _tBase, _vInt, _vFrac >::int_bit_n = _vInt
static

整数部分二进制位数。

在文件 rational.hpp119 行定义.

template<typename _tBase = std::int32_t, size_t _vInt = std::numeric_limits<_tBase>::digits - 6U, size_t _vFrac = std::numeric_limits<_tBase>::digits - _vInt>
base_type ystdex::fixed_point< _tBase, _vInt, _vFrac >::value
private

该类的文档由以下文件生成: