MSTL 1.4.0
A Modern C++ Library with extended functionality, web components, and utility libraries
载入中...
搜索中...
未找到
数学函数

基本数学运算函数 更多...

函数

MSTL_PURE_FUNCTION MSTL_CONSTEXPR14 uint64_t fibonacci (const uint32_t n)
 计算斐波那契数
MSTL_PURE_FUNCTION MSTL_CONSTEXPR14 uint64_t leonardo (const uint32_t n)
 计算莱昂纳多数
template<typename T>
MSTL_PURE_FUNCTION constexpr T angular2radian (const T angular) noexcept
 角度转弧度
template<typename T>
MSTL_PURE_FUNCTION constexpr T radian2angular (const T radian) noexcept
 弧度转角度
template<typename T>
MSTL_CONST_FUNCTION constexpr enable_if_t< is_signed_v< T >, T > absolute (const T x) noexcept
 取绝对值(有符号数版本)
template<typename T>
MSTL_CONST_FUNCTION constexpr const T & sum (const T &x) noexcept
 单参数求和
template<typename First, typename... Rests, enable_if_t<(sizeof...(Rests) > 0), int > = 0>
MSTL_CONST_FUNCTION constexpr decltype(auto) sum (First first, Rests... args)
 多参数求和
template<typename... Args, enable_if_t<(sizeof...(Args) > 0), int > = 0>
MSTL_CONST_FUNCTION constexpr decltype(auto) average (Args... args)
 计算平均值
template<typename T>
MSTL_CONSTEXPR14 int sign (const T &value) noexcept
 获取数值的符号
template<typename T>
MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 T gcd (const T &m, const T &n) noexcept
 计算最大公约数
template<typename T>
MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 T lcm (const T &m, const T &n) noexcept
 计算最小公倍数
template<typename T>
MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 T float_mod (const T x, const T y)
 浮点数取模运算
template<typename T>
MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 T power (const T &x, uint32_t n) noexcept
 幂运算
MSTL_PURE_FUNCTION MSTL_CONSTEXPR14 decimal_t exponential (const uint32_t n) noexcept
 计算e的n次幂
template<typename T>
MSTL_PURE_FUNCTION MSTL_CONSTEXPR14 T logarithm_e (const T x) noexcept
 计算自然对数
template<typename T>
MSTL_PURE_FUNCTION MSTL_CONSTEXPR14 T logarithm (const T x, const uint32_t base)
 计算任意底数的对数
template<typename T>
MSTL_PURE_FUNCTION MSTL_CONSTEXPR14 T logarithm_2 (const T x)
 计算以2为底的对数
template<typename T>
MSTL_PURE_FUNCTION MSTL_CONSTEXPR14 T logarithm_10 (const T x)
 计算以10为底的对数
MSTL_PURE_FUNCTION MSTL_CONSTEXPR14 decimal_t square_root (const decimal_t x, const decimal_t precise=_CONSTANTS PRECISE_TOLERANCE) noexcept
 计算平方根
MSTL_PURE_FUNCTION MSTL_CONSTEXPR14 decimal_t cube_root (const decimal_t x, const decimal_t precise=_CONSTANTS PRECISE_TOLERANCE) noexcept
 计算立方根
MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 uint64_t factorial (const uint32_t n) noexcept
 计算阶乘
MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 decimal_t floor_bit (const decimal_t x, const uint32_t bit) noexcept
 向下舍入到指定位数
MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 decimal_t ceil_bit (const decimal_t x, const uint32_t bit) noexcept
 向上舍入到指定位数
MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 decimal_t round_bit (const decimal_t x, const uint32_t bit) noexcept
 四舍五入到指定位数
MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 decimal_t truncate_bit (const decimal_t x, const uint32_t bit) noexcept
 截断到指定位数
MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 decimal_t floor (const decimal_t x) noexcept
 向下取整
MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 decimal_t floor (const decimal_t x, const uint32_t bit) noexcept
 向下取整到指定位数
MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 decimal_t ceil (const decimal_t x) noexcept
 向上取整
MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 decimal_t ceil (const decimal_t x, const uint32_t bit) noexcept
 向上取整到指定位数
MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 decimal_t round (const decimal_t x) noexcept
 四舍五入
MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 decimal_t round (const decimal_t x, const uint32_t bit) noexcept
 四舍五入到指定位数
MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 decimal_t truncate (const decimal_t x, const int bit) noexcept
 截断
MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 decimal_t truncate (const decimal_t x) noexcept
 截断到整数位
MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 bool around_multiple (const decimal_t x, const decimal_t axis, const decimal_t toler=_CONSTANTS PRECISE_TOLERANCE)
 判断是否接近某个倍数值
MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 bool around_pi (const decimal_t x, const decimal_t toler=_CONSTANTS LOW_PRECISE_TOLERANCE)
 判断是否接近π的整数倍
MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 bool around_zero (const decimal_t x, const decimal_t toler=_CONSTANTS PRECISE_TOLERANCE)
 判断是否接近零
MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 decimal_t remainder (const decimal_t x, const decimal_t y) noexcept
 计算余数
MSTL_CONST_FUNCTION constexpr decimal_t float_part (const decimal_t x) noexcept
 获取小数部分
MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 decimal_t float_apart (decimal_t x, int64_t *int_ptr) noexcept
 分离整数和小数部分
MSTL_PURE_FUNCTION MSTL_CONSTEXPR14 decimal_t sine (decimal_t x) noexcept
 计算正弦值
MSTL_PURE_FUNCTION MSTL_CONSTEXPR14 decimal_t cosine (const decimal_t x) noexcept
 计算余弦值
MSTL_PURE_FUNCTION MSTL_CONSTEXPR14 decimal_t tangent (const decimal_t x)
 计算正切值
MSTL_PURE_FUNCTION MSTL_CONSTEXPR14 decimal_t cotangent (const decimal_t x)
 计算余切值
MSTL_PURE_FUNCTION MSTL_CONSTEXPR14 decimal_t arctangent (const decimal_t x) noexcept
 计算反正切值
MSTL_PURE_FUNCTION MSTL_CONSTEXPR14 decimal_t arcsine (const decimal_t x)
 计算反正弦值
MSTL_PURE_FUNCTION MSTL_CONSTEXPR14 decimal_t arccosine (const decimal_t x)
 计算反余弦值

详细描述

基本数学运算函数

函数说明

◆ absolute()

template<typename T>
MSTL_CONST_FUNCTION constexpr enable_if_t< is_signed_v< T >, T > absolute ( const T x)
constexprnoexcept

取绝对值(有符号数版本)

模板参数
T数值类型
参数
x原数值
返回
绝对值

在文件 math.hpp126 行定义.

被这些函数引用 arccosine(), arcsine(), arctangent(), around_multiple(), around_zero(), cube_root(), gcd(), is_normal(), is_subnormal(), sine(), square_root() , 以及 tangent().

◆ angular2radian()

template<typename T>
MSTL_PURE_FUNCTION constexpr T angular2radian ( const T angular)
constexprnoexcept

角度转弧度

模板参数
T运算类型
参数
angular角度值
返回
对应的弧度值

在文件 math.hpp101 行定义.

引用了 _CONSTANTS, PI , 以及 SEMI_CIRCLE.

◆ arccosine()

MSTL_PURE_FUNCTION MSTL_CONSTEXPR14 decimal_t arccosine ( const decimal_t x)

计算反余弦值

参数
x参数(|x| ≤ 1)
返回
arccos(x)(弧度值,范围[0, π])
异常
math_exception当|x| > 1时抛出

在文件 math.hpp735 行定义.

引用了 _CONSTANTS, _MSTL, absolute(), arcsine() , 以及 PI.

◆ arcsine()

MSTL_PURE_FUNCTION MSTL_CONSTEXPR14 decimal_t arcsine ( const decimal_t x)

计算反正弦值

参数
x参数(|x| ≤ 1)
返回
arcsin(x)(弧度值,范围[-π/2, π/2])
异常
math_exception当|x| > 1时抛出

在文件 math.hpp722 行定义.

引用了 _MSTL, absolute(), arctangent() , 以及 square_root().

被这些函数引用 arccosine().

◆ arctangent()

MSTL_PURE_FUNCTION MSTL_CONSTEXPR14 decimal_t arctangent ( const decimal_t x)
noexcept

计算反正切值

参数
x参数
返回
arctan(x)(弧度值,范围(-π/2, π/2))

当|x|>1时,利用恒等式 arctan(x) = π/2 - arctan(1/x)。

在文件 math.hpp708 行定义.

引用了 _CONSTANTS, _INNER, absolute(), PI , 以及 sign().

被这些函数引用 arcsine().

◆ around_multiple()

MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 bool around_multiple ( const decimal_t x,
const decimal_t axis,
const decimal_t toler = _CONSTANTS PRECISE_TOLERANCE )

判断是否接近某个倍数值

参数
x待判断值
axis基准值
toler容差
返回
如果x接近axis的整数倍则返回true
异常
math_exception当axis为0时抛出

在文件 math.hpp529 行定义.

引用了 _CONSTANTS, _MSTL, absolute(), PRECISE_TOLERANCE , 以及 round().

被这些函数引用 around_pi().

◆ around_pi()

MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 bool around_pi ( const decimal_t x,
const decimal_t toler = _CONSTANTS LOW_PRECISE_TOLERANCE )

判断是否接近π的整数倍

参数
x待判断值
toler容差
返回
如果x接近π的整数倍则返回true

在文件 math.hpp544 行定义.

引用了 _CONSTANTS, around_multiple(), LOW_PRECISE_TOLERANCE , 以及 PI.

◆ around_zero()

MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 bool around_zero ( const decimal_t x,
const decimal_t toler = _CONSTANTS PRECISE_TOLERANCE )

判断是否接近零

参数
x待判断值
toler容差
返回
如果|x| < toler则返回true

在文件 math.hpp555 行定义.

引用了 _CONSTANTS, absolute() , 以及 PRECISE_TOLERANCE.

被这些函数引用 sine().

◆ average()

template<typename... Args, enable_if_t<(sizeof...(Args) > 0), int > = 0>
MSTL_CONST_FUNCTION constexpr decltype(auto) average ( Args... args)
constexpr

计算平均值

模板参数
Args参数类型
参数
args要求平均值的参数
返回
平均值

在文件 math.hpp176 行定义.

引用了 _MSTL , 以及 sum().

◆ ceil() [1/2]

MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 decimal_t ceil ( const decimal_t x)
noexcept

◆ ceil() [2/2]

MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 decimal_t ceil ( const decimal_t x,
const uint32_t bit )
noexcept

向上取整到指定位数

参数
x原数值
bit位数
返回
向上取整后的值

在文件 math.hpp476 行定义.

引用了 ceil() , 以及 power().

◆ ceil_bit()

MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 decimal_t ceil_bit ( const decimal_t x,
const uint32_t bit )
noexcept

向上舍入到指定位数

参数
x原数值
bit位数
返回
向上舍入后的值

在文件 math.hpp410 行定义.

引用了 power().

被这些函数引用 round_bit() , 以及 truncate_bit().

◆ cosine()

MSTL_PURE_FUNCTION MSTL_CONSTEXPR14 decimal_t cosine ( const decimal_t x)
noexcept

计算余弦值

参数
x弧度值
返回
cos(x)

利用恒等式 cos(x) = sin(π/2 - x) 计算。

在文件 math.hpp646 行定义.

引用了 _CONSTANTS, PI , 以及 sine().

被这些函数引用 tangent().

◆ cotangent()

MSTL_PURE_FUNCTION MSTL_CONSTEXPR14 decimal_t cotangent ( const decimal_t x)

计算余切值

参数
x弧度值
返回
cot(x)
异常
math_exception当x接近π的整数倍时抛出

在文件 math.hpp671 行定义.

引用了 tangent().

◆ cube_root()

MSTL_PURE_FUNCTION MSTL_CONSTEXPR14 decimal_t cube_root ( const decimal_t x,
const decimal_t precise = _CONSTANTS PRECISE_TOLERANCE )
noexcept

计算立方根

参数
x被开方数
precise精度要求
返回
³√x

使用牛顿迭代法计算。

在文件 math.hpp366 行定义.

引用了 _CONSTANTS, absolute() , 以及 PRECISE_TOLERANCE.

◆ exponential()

MSTL_PURE_FUNCTION MSTL_CONSTEXPR14 decimal_t exponential ( const uint32_t n)
noexcept

计算e的n次幂

参数
n指数
返回
e^n

在文件 math.hpp273 行定义.

引用了 _CONSTANTS, EULER , 以及 power().

◆ factorial()

MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 uint64_t factorial ( const uint32_t n)
noexcept

计算阶乘

参数
n非负整数
返回
n!

在文件 math.hpp381 行定义.

◆ fibonacci()

MSTL_PURE_FUNCTION MSTL_CONSTEXPR14 uint64_t fibonacci ( const uint32_t n)

计算斐波那契数

参数
n索引位置
返回
第n个斐波那契数

如果n小于预计算的数量,直接返回预计算结果; 否则递归计算。

在文件 math.hpp76 行定义.

引用了 _CONSTANTS, fibonacci(), FIBONACCI_COUNT , 以及 FIBONACCI_LIST.

被这些函数引用 fibonacci() , 以及 leonardo().

◆ float_apart()

MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 decimal_t float_apart ( decimal_t x,
int64_t * int_ptr )
noexcept

分离整数和小数部分

参数
x原数值
int_ptr指向整数部分的指针
返回
小数部分

将x的整数部分存入int_ptr,返回小数部分。

在文件 math.hpp590 行定义.

◆ float_mod()

template<typename T>
MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 T float_mod ( const T x,
const T y )

浮点数取模运算

模板参数
T浮点类型
参数
x被除数
y除数
返回
x除以y的余数
异常
math_exception当除数为0时抛出

在文件 math.hpp236 行定义.

◆ float_part()

MSTL_CONST_FUNCTION constexpr decimal_t float_part ( const decimal_t x)
constexprnoexcept

获取小数部分

参数
x原数值
返回
x的小数部分

在文件 math.hpp578 行定义.

◆ floor() [1/2]

MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 decimal_t floor ( const decimal_t x)
noexcept

向下取整

参数
x原数值
返回
向下取整后的值

在文件 math.hpp446 行定义.

被这些函数引用 bit_ceil(), floor(), round(), sine() , 以及 truncate().

◆ floor() [2/2]

MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 decimal_t floor ( const decimal_t x,
const uint32_t bit )
noexcept

向下取整到指定位数

参数
x原数值
bit位数
返回
向下取整后的值

在文件 math.hpp456 行定义.

引用了 floor() , 以及 power().

◆ floor_bit()

MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 decimal_t floor_bit ( const decimal_t x,
const uint32_t bit )
noexcept

向下舍入到指定位数

参数
x原数值
bit位数,>0表示小数位,0表示整数位
返回
向下舍入后的值

在文件 math.hpp396 行定义.

引用了 power().

被这些函数引用 round_bit() , 以及 truncate_bit().

◆ gcd()

template<typename T>
MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 T gcd ( const T & m,
const T & n )
noexcept

计算最大公约数

模板参数
T数值类型
参数
m第一个数
n第二个数
返回
最大公约数

在文件 math.hpp203 行定义.

引用了 _MSTL , 以及 absolute().

被这些函数引用 lcm().

◆ lcm()

template<typename T>
MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 T lcm ( const T & m,
const T & n )
noexcept

计算最小公倍数

模板参数
T数值类型
参数
m第一个数
n第二个数
返回
最小公倍数

在文件 math.hpp222 行定义.

引用了 _MSTL , 以及 gcd().

◆ leonardo()

MSTL_PURE_FUNCTION MSTL_CONSTEXPR14 uint64_t leonardo ( const uint32_t n)

计算莱昂纳多数

参数
n索引位置
返回
第n个莱昂纳多数

莱昂纳多数:L(n) = 2 * F(n+1) - 1

在文件 math.hpp90 行定义.

引用了 fibonacci().

◆ logarithm()

template<typename T>
MSTL_PURE_FUNCTION MSTL_CONSTEXPR14 T logarithm ( const T x,
const uint32_t base )

计算任意底数的对数

模板参数
T运算类型
参数
x真数
base底数
返回
以base为底x的对数

在文件 math.hpp308 行定义.

引用了 _MSTL , 以及 logarithm_e().

被这些函数引用 logarithm_10() , 以及 logarithm_2().

◆ logarithm_10()

template<typename T>
MSTL_PURE_FUNCTION MSTL_CONSTEXPR14 T logarithm_10 ( const T x)

计算以10为底的对数

模板参数
T运算类型
参数
x真数
返回
log₁₀(x)

在文件 math.hpp334 行定义.

引用了 _MSTL , 以及 logarithm().

◆ logarithm_2()

template<typename T>
MSTL_PURE_FUNCTION MSTL_CONSTEXPR14 T logarithm_2 ( const T x)

计算以2为底的对数

模板参数
T运算类型
参数
x真数
返回
log₂(x)

在文件 math.hpp323 行定义.

引用了 _MSTL , 以及 logarithm().

◆ logarithm_e()

template<typename T>
MSTL_PURE_FUNCTION MSTL_CONSTEXPR14 T logarithm_e ( const T x)
noexcept

计算自然对数

模板参数
T运算类型
参数
x真数
返回
ln(x)

使用反正切泰勒展开计算。

在文件 math.hpp286 行定义.

引用了 _CONSTANTS , 以及 TAYLOR_CONVERGENCE.

被这些函数引用 logarithm().

◆ power()

template<typename T>
MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 T power ( const T & x,
uint32_t n )
noexcept

幂运算

模板参数
T底数类型
参数
x底数
n指数
返回
x的n次幂

使用快速幂算法实现。

在文件 math.hpp253 行定义.

被这些函数引用 ceil(), ceil_bit(), exponential(), floor(), floor_bit(), round() , 以及 round_bit().

◆ radian2angular()

template<typename T>
MSTL_PURE_FUNCTION constexpr T radian2angular ( const T radian)
constexprnoexcept

弧度转角度

模板参数
T运算类型
参数
radian弧度值
返回
对应的角度值

在文件 math.hpp113 行定义.

引用了 _CONSTANTS, PI , 以及 SEMI_CIRCLE.

◆ remainder()

MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 decimal_t remainder ( const decimal_t x,
const decimal_t y )
noexcept

计算余数

参数
x被除数
y除数
返回
x除以y的余数

使用对称舍入规则

在文件 math.hpp569 行定义.

引用了 _MSTL , 以及 round().

◆ round() [1/2]

MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 decimal_t round ( const decimal_t x)
noexcept

四舍五入

参数
x原数值
返回
四舍五入后的值

在文件 math.hpp486 行定义.

引用了 ceil() , 以及 floor().

被这些函数引用 around_multiple(), remainder(), round() , 以及 tangent().

◆ round() [2/2]

MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 decimal_t round ( const decimal_t x,
const uint32_t bit )
noexcept

四舍五入到指定位数

参数
x原数值
bit位数
返回
四舍五入后的值

在文件 math.hpp496 行定义.

引用了 power() , 以及 round().

◆ round_bit()

MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 decimal_t round_bit ( const decimal_t x,
const uint32_t bit )
noexcept

四舍五入到指定位数

参数
x原数值
bit位数
返回
四舍五入后的值

在文件 math.hpp424 行定义.

引用了 ceil_bit(), floor_bit() , 以及 power().

◆ sign()

template<typename T>
MSTL_CONSTEXPR14 int sign ( const T & value)
noexcept

获取数值的符号

模板参数
T数值类型
参数
value原数值
返回
符号值:正数返回1,负数返回-1,零返回0

在文件 math.hpp187 行定义.

被这些函数引用 arctangent() , 以及 sine().

◆ sine()

MSTL_PURE_FUNCTION MSTL_CONSTEXPR14 decimal_t sine ( decimal_t x)
noexcept

计算正弦值

参数
x弧度值
返回
sin(x)

使用泰勒展开计算,先进行周期性处理。

在文件 math.hpp604 行定义.

引用了 _CONSTANTS, absolute(), around_zero(), EPSILON, floor(), PI, sign() , 以及 sum().

被这些函数引用 cosine() , 以及 tangent().

◆ square_root()

MSTL_PURE_FUNCTION MSTL_CONSTEXPR14 decimal_t square_root ( const decimal_t x,
const decimal_t precise = _CONSTANTS PRECISE_TOLERANCE )
noexcept

计算平方根

参数
x被开方数
precise精度要求
返回
√x

使用牛顿迭代法计算。

在文件 math.hpp347 行定义.

引用了 _CONSTANTS, absolute() , 以及 PRECISE_TOLERANCE.

被这些函数引用 arcsine().

◆ sum() [1/2]

template<typename T>
MSTL_CONST_FUNCTION constexpr const T & sum ( const T & x)
constexprnoexcept

单参数求和

模板参数
T数值类型
参数
x唯一参数
返回
参数本身

递归sum的终止位置

在文件 math.hpp152 行定义.

被这些函数引用 average(), sine() , 以及 sum().

◆ sum() [2/2]

template<typename First, typename... Rests, enable_if_t<(sizeof...(Rests) > 0), int > = 0>
MSTL_CONST_FUNCTION constexpr decltype(auto) sum ( First first,
Rests... args )
constexpr

多参数求和

模板参数
First第一个参数类型
Rests剩余参数类型
参数
first第一个参数
args剩余参数
返回
所有参数的和

在文件 math.hpp165 行定义.

引用了 _MSTL , 以及 sum().

◆ tangent()

MSTL_PURE_FUNCTION MSTL_CONSTEXPR14 decimal_t tangent ( const decimal_t x)

计算正切值

参数
x弧度值
返回
tan(x)
异常
math_exception当x接近π/2的奇数倍时抛出

在文件 math.hpp656 行定义.

引用了 _CONSTANTS, _MSTL, absolute(), cosine(), LOW_PRECISE_TOLERANCE, PI, round() , 以及 sine().

被这些函数引用 cotangent().

◆ truncate() [1/2]

MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 decimal_t truncate ( const decimal_t x)
noexcept

截断到整数位

参数
x原数值
返回
截断后的整数值

在文件 math.hpp516 行定义.

引用了 truncate().

◆ truncate() [2/2]

MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 decimal_t truncate ( const decimal_t x,
const int bit )
noexcept

截断

参数
x原数值
bit位数
返回
截断后的值

在文件 math.hpp507 行定义.

引用了 ceil() , 以及 floor().

被这些函数引用 truncate().

◆ truncate_bit()

MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 decimal_t truncate_bit ( const decimal_t x,
const uint32_t bit )
noexcept

截断到指定位数

参数
x原数值
bit位数
返回
截断后的值

在文件 math.hpp436 行定义.

引用了 ceil_bit() , 以及 floor_bit().