mFrame
載入中...
搜尋中...
無符合項目
Maths.h
1
7#ifndef MFRAME_EEC25F8B_68C8_45FC_A820_3773DB4D7EF7
8#define MFRAME_EEC25F8B_68C8_45FC_A820_3773DB4D7EF7
9
10/* ***************************************************************************************
11 * Include
12 */
13
14//----------------------------------------------------------------------------------------
15#include "./../lang/NonInstantiable.h"
16
17/* ***************************************************************************************
18 * Namespace
19 */
20namespace ufm::lang {
21 class Maths;
22} // namespace ufm::lang
23
24/* ***************************************************************************************
25 * Class Math
26 */
27
37 /* *************************************************************************************
38 * Subclass
39 */
40
41 /* *************************************************************************************
42 * Variable
43 */
44
45 /* *************************************************************************************
46 * Abstract Method
47 */
48
49 /* *************************************************************************************
50 * Construct Method
51 */
52 protected:
57 virtual ~Maths(void) override = default;
58
59 /* *************************************************************************************
60 * Operator Method
61 */
62
63 /* *************************************************************************************
64 * Override Method
65 */
66
67 /* *************************************************************************************
68 * Public Method
69 */
70
71 /* *************************************************************************************
72 * Protected Method
73 */
74
75 /* *************************************************************************************
76 * Private Method
77 */
78
79 /* *************************************************************************************
80 * Static Variable
81 */
82
83 /* *************************************************************************************
84 * Static Method
85 */
86 public:
93 static double acos(double x);
94
101 static double asin(double x);
102
109 static double atan(double x);
110
118 static double atan2(double y, double x);
119
126 static double cos(double x);
127
134 static double cosh(double x);
135
142 static double sin(double x);
143
150 static double sinh(double x);
151
158 static double tanh(double x);
159
167 static double frexp(double x, int *exponent);
168
176 static double ldexp(double x, int exponent);
177
184 static double log(double x);
185
192 static double log10(double x);
193
203 static double modf(double x, double *integer);
204
214 static double pow(double x, double y);
215
224 static double sqrt(double x);
225
234 static double ceil(double x);
235
244 static double fabs(double x);
245
254 static float fabsf(float x);
255
264 static double floor(double x);
265
275 static double fmod(double x, double y);
276
285 static inline int abs(int a) {
286 if (a < 0) return ~a;
287
288 return a;
289 }
290
299 static inline long abs(long a) {
300 if (a < 0) return (a * (-1));
301
302 return a;
303 }
304
313 static inline float abs(float a) {
314 if (a < 0) return (a * (-1));
315
316 return a;
317 }
318
325 static inline uint32 align32bit(uint32 value) {
326 if (value & 0x00000003UL) return (value & 0xFFFFFFF4UL) + 4;
327
328 return value;
329 }
330
337 static inline uint32 align64bit(uint32 value) {
338 if (value & 0x00000007UL) return (value & 0xFFFFFFF8UL) + 8;
339
340 return value;
341 }
342
350 static inline int ceil(int dividend, int divisor) {
351 return (dividend + (divisor - 1)) / divisor;
352 }
353
361 static inline uint32 ceil(uint32 dividend, uint32 divisor) {
362 return (dividend + (divisor - 1)) / divisor;
363 }
364
372 static inline uint32 min(uint32 a, uint32 b) {
373 return ((a) < (b) ? (a) : (b));
374 }
375
383 static inline int min(int a, int b) {
384 return ((a) < (b) ? (a) : (b));
385 }
386
394 static inline uint32 max(uint32 a, uint32 b) {
395 return ((a) > (b) ? (a) : (b));
396 }
397
405 static inline int max(int a, int b) {
406 return ((a) > (b) ? (a) : (b));
407 }
408};
409
410/* ***************************************************************************************
411 * End of file
412 */
413
414#endif /* MFRAME_EEC25F8B_68C8_45FC_A820_3773DB4D7EF7 */
數學運算工具類別
Definition Maths.h:36
static double pow(double x, double y)
返回 x 的 y 次方
static double asin(double x)
返回x的正弦弧線弧度。
static double ldexp(double x, int exponent)
返回 x 乘以 2 的 exponent 次方。
static float abs(float a)
回傳浮點數的絕對值。如果參數為非負數,則直接回傳該值;若為負數則回傳其相反數。
Definition Maths.h:313
virtual ~Maths(void) override=default
Destroy the Maths object.
static uint32 align32bit(uint32 value)
32位元位址對齊。
Definition Maths.h:325
static double acos(double x)
返回x的反餘弦弧度。
static double atan2(double y, double x)
返回y/x的反正切值(弧度),以判別正確象限。
static double log(double x)
返回x的自然對數(以E為底)。
static long abs(long a)
回傳長整數的絕對值。如果參數為非負數,則直接回傳該值;若為負數則回傳其相反數。
Definition Maths.h:299
static double atan(double x)
返回x的反正切值,以弧度為單位。
static double cos(double x)
返回弧度角x的餘弦值。
static double ceil(double x)
向上取整
static double tanh(double x)
返回x的雙曲正切值。
static double sin(double x)
返回弧度角x的正弦值。
static double fmod(double x, double y)
取餘數
static double sqrt(double x)
計算 x 的平方根
static double sinh(double x)
返回x的雙曲正弦值。
static double log10(double x)
返回x的常用對數(以10為底)。
static double fabs(double x)
計算 x 的絕對值 (雙精度)
static double floor(double x)
向下取整
static int abs(int a)
回傳整數的絕對值。如果參數為非負數,則直接回傳該值;若為負數則回傳其相反數。
Definition Maths.h:285
static uint32 ceil(uint32 dividend, uint32 divisor)
向上取整(無符號整數版本)。
Definition Maths.h:361
static uint32 align64bit(uint32 value)
64位元位址對齊。
Definition Maths.h:337
static int ceil(int dividend, int divisor)
向上取整(整數版本)。
Definition Maths.h:350
static uint32 min(uint32 a, uint32 b)
回傳兩個無符號整數中的較小值。
Definition Maths.h:372
static double modf(double x, double *integer)
分解浮點值 x 為整數與小數部分
static double frexp(double x, int *exponent)
返回x的尾數與指數,滿足 x = 尾數 * 2^指數。
static int max(int a, int b)
回傳兩個整數中的較大值。
Definition Maths.h:405
static float fabsf(float x)
計算 x 的絕對值 (單精度)
static double cosh(double x)
返回x的雙曲餘弦值。
static uint32 max(uint32 a, uint32 b)
回傳兩個無符號整數中的較大值。
Definition Maths.h:394
static int min(int a, int b)
回傳兩個整數中的較小值。
Definition Maths.h:383
Definition NonInstantiable.h:29
Definition Appendable.h:23