數學運算工具類別
更多...
#include <Maths.h>
|
static double | acos (double x) |
| 返回x的反餘弦弧度。
|
|
static double | asin (double x) |
| 返回x的正弦弧線弧度。
|
|
static double | atan (double x) |
| 返回x的反正切值,以弧度為單位。
|
|
static double | atan2 (double y, double x) |
| 返回y/x的反正切值(弧度),以判別正確象限。
|
|
static double | cos (double x) |
| 返回弧度角x的餘弦值。
|
|
static double | cosh (double x) |
| 返回x的雙曲餘弦值。
|
|
static double | sin (double x) |
| 返回弧度角x的正弦值。
|
|
static double | sinh (double x) |
| 返回x的雙曲正弦值。
|
|
static double | tanh (double x) |
| 返回x的雙曲正切值。
|
|
static double | frexp (double x, int *exponent) |
| 返回x的尾數與指數,滿足 x = 尾數 * 2^指數。
|
|
static double | ldexp (double x, int exponent) |
| 返回 x 乘以 2 的 exponent 次方。
|
|
static double | log (double x) |
| 返回x的自然對數(以E為底)。
|
|
static double | log10 (double x) |
| 返回x的常用對數(以10為底)。
|
|
static double | modf (double x, double *integer) |
| 分解浮點值 x 為整數與小數部分
|
|
static double | pow (double x, double y) |
| 返回 x 的 y 次方
|
|
static double | sqrt (double x) |
| 計算 x 的平方根
|
|
static double | ceil (double x) |
| 向上取整
|
|
static double | fabs (double x) |
| 計算 x 的絕對值 (雙精度)
|
|
static float | fabsf (float x) |
| 計算 x 的絕對值 (單精度)
|
|
static double | floor (double x) |
| 向下取整
|
|
static double | fmod (double x, double y) |
| 取餘數
|
|
static constexpr int | abs (int a) |
| 回傳整數的絕對值。如果參數為非負數,則直接回傳該值;若為負數則回傳其相反數。
|
|
static constexpr long | abs (long a) |
| 回傳長整數的絕對值。如果參數為非負數,則直接回傳該值;若為負數則回傳其相反數。
|
|
static constexpr float | abs (float a) |
| 回傳浮點數的絕對值。如果參數為非負數,則直接回傳該值;若為負數則回傳其相反數。
|
|
static uint32 | align32bit (uint32 value) |
| 32位元位址對齊。
|
|
static uint32 | align64bit (uint32 value) |
| 64位元位址對齊。
|
|
static uint32 | floorPowerOf2 (uint32 value) |
|
static uint32 | ceilPowerOf2 (uint32 value) |
|
static uint32 | floorShiftCount (uint32 value) |
|
static uint32 | ceilShiftCount (uint32 value) |
|
static constexpr int | ceil (int dividend, int divisor) |
| 向上取整(整數版本)。
|
|
static constexpr uint32 | ceil (uint32 dividend, uint32 divisor) |
| 向上取整(無符號整數版本)。
|
|
static constexpr uint32 | min (uint32 a, uint32 b) |
| 回傳兩個無符號整數中的較小值。
|
|
static constexpr int | min (int a, int b) |
| 回傳兩個整數中的較小值。
|
|
static constexpr uint32 | max (uint32 a, uint32 b) |
| 回傳兩個無符號整數中的較大值。
|
|
static constexpr int | max (int a, int b) |
| 回傳兩個整數中的較大值。
|
|
static constexpr uint32 | log2 (uint32 n, uint32 p=0) |
| 計算無符號整數的二進位對數(以2為底)。
|
|
數學運算工具類別
本類別提供各式數學運算方法,包括三角函數、對數、指數、平方根及其他常用數學運算。 所有方法皆以靜態方式提供,直接封裝自標準 C++ 數學函式庫,以方便使用者調用。
- 註
- 此類別不允許建立實例(建構子設定為 private),僅作為工具函式集合使用。
- 範例
- F:/mframe/doxy-document/src/mframe/src/ufm/lang/Maths.h.
◆ abs() [1/3]
static constexpr float ufm::lang::Maths::abs |
( |
float | a | ) |
|
|
inlinestaticconstexpr |
回傳浮點數的絕對值。如果參數為非負數,則直接回傳該值;若為負數則回傳其相反數。
注意:如果參數等於 Float.MIN_VALUE(可表示的最小浮點數),結果仍為該值(仍為負數)。
- 參數
-
- 傳回值
- 參數 a 的絕對值
◆ abs() [2/3]
static constexpr int ufm::lang::Maths::abs |
( |
int | a | ) |
|
|
inlinestaticconstexpr |
◆ abs() [3/3]
static constexpr long ufm::lang::Maths::abs |
( |
long | a | ) |
|
|
inlinestaticconstexpr |
回傳長整數的絕對值。如果參數為非負數,則直接回傳該值;若為負數則回傳其相反數。
注意:如果參數等於 Long.MIN_VALUE(可表示的最小長整數),結果仍為該值(仍為負數)。
- 參數
-
- 傳回值
- 參數 a 的絕對值
◆ acos()
static double ufm::lang::Maths::acos |
( |
double | x | ) |
|
|
static |
◆ align32bit()
static uint32 ufm::lang::Maths::align32bit |
( |
uint32 | value | ) |
|
|
inlinestatic |
◆ align64bit()
static uint32 ufm::lang::Maths::align64bit |
( |
uint32 | value | ) |
|
|
inlinestatic |
◆ asin()
static double ufm::lang::Maths::asin |
( |
double | x | ) |
|
|
static |
◆ atan()
static double ufm::lang::Maths::atan |
( |
double | x | ) |
|
|
static |
◆ atan2()
static double ufm::lang::Maths::atan2 |
( |
double | y, |
|
|
double | x ) |
|
static |
◆ ceil() [1/3]
static double ufm::lang::Maths::ceil |
( |
double | x | ) |
|
|
static |
◆ ceil() [2/3]
static constexpr int ufm::lang::Maths::ceil |
( |
int | dividend, |
|
|
int | divisor ) |
|
inlinestaticconstexpr |
◆ ceil() [3/3]
static constexpr uint32 ufm::lang::Maths::ceil |
( |
uint32 | dividend, |
|
|
uint32 | divisor ) |
|
inlinestaticconstexpr |
向上取整(無符號整數版本)。
- 參數
-
- 傳回值
- 取整後的結果
◆ cos()
static double ufm::lang::Maths::cos |
( |
double | x | ) |
|
|
static |
◆ cosh()
static double ufm::lang::Maths::cosh |
( |
double | x | ) |
|
|
static |
◆ fabs()
static double ufm::lang::Maths::fabs |
( |
double | x | ) |
|
|
static |
◆ fabsf()
static float ufm::lang::Maths::fabsf |
( |
float | x | ) |
|
|
static |
◆ floor()
static double ufm::lang::Maths::floor |
( |
double | x | ) |
|
|
static |
◆ fmod()
static double ufm::lang::Maths::fmod |
( |
double | x, |
|
|
double | y ) |
|
static |
◆ frexp()
static double ufm::lang::Maths::frexp |
( |
double | x, |
|
|
int * | exponent ) |
|
static |
◆ ldexp()
static double ufm::lang::Maths::ldexp |
( |
double | x, |
|
|
int | exponent ) |
|
static |
◆ log()
static double ufm::lang::Maths::log |
( |
double | x | ) |
|
|
static |
◆ log10()
static double ufm::lang::Maths::log10 |
( |
double | x | ) |
|
|
static |
◆ log2()
static constexpr uint32 ufm::lang::Maths::log2 |
( |
uint32 | n, |
|
|
uint32 | p = 0 ) |
|
inlinestaticconstexpr |
◆ max() [1/2]
static constexpr int ufm::lang::Maths::max |
( |
int | a, |
|
|
int | b ) |
|
inlinestaticconstexpr |
◆ max() [2/2]
static constexpr uint32 ufm::lang::Maths::max |
( |
uint32 | a, |
|
|
uint32 | b ) |
|
inlinestaticconstexpr |
◆ min() [1/2]
static constexpr int ufm::lang::Maths::min |
( |
int | a, |
|
|
int | b ) |
|
inlinestaticconstexpr |
◆ min() [2/2]
static constexpr uint32 ufm::lang::Maths::min |
( |
uint32 | a, |
|
|
uint32 | b ) |
|
inlinestaticconstexpr |
◆ modf()
static double ufm::lang::Maths::modf |
( |
double | x, |
|
|
double * | integer ) |
|
static |
◆ pow()
static double ufm::lang::Maths::pow |
( |
double | x, |
|
|
double | y ) |
|
static |
◆ sin()
static double ufm::lang::Maths::sin |
( |
double | x | ) |
|
|
static |
◆ sinh()
static double ufm::lang::Maths::sinh |
( |
double | x | ) |
|
|
static |
◆ sqrt()
static double ufm::lang::Maths::sqrt |
( |
double | x | ) |
|
|
static |
◆ tanh()
static double ufm::lang::Maths::tanh |
( |
double | x | ) |
|
|
static |
此類別(class) 文件是由下列檔案中產生: