一些常用的函數
rand() ----隨機數
abs() / labs() ----整數絕對值
fabs() / fabsf() / fabsl() ----浮點數絕對值
floor() / floorf() / floorl() ----向下取整
ceil() / ceilf() / ceill() ----向上取整
round() / roundf() / roundl() ----四舍五入
sqrt() / sqrtf() / sqrtl() ----求平方根
fmax() / fmaxf() / fmaxl() ----求最大值
fmin() / fminf() / fminl() ----求最小值
hypot() / hypotf() / hypotl() ----求直角三角形斜邊的長度
fmod() / fmodf() / fmodl() ----求兩數整除后的余數
modf() / modff() / modfl() ----浮點數分解為整數和小數
frexp() / frexpf() / frexpl() ----浮點數分解尾數和二為底的指數
sin() / sinf() / sinl() ----求正弦值
sinh() / sinhf() / sinhl() ----求雙曲正弦值
cos() / cosf() / cosl() ----求余弦值
cosh() / coshf() / coshl() ----求雙曲余弦值
tan() / tanf() / tanl() ----求正切值
tanh() / tanhf() / tanhl() ----求雙曲正切值
asin() / asinf() / asinl() ----求反正弦值
asinh() / asinhf() / asinhl() ----求反雙曲正弦值
acos() / acosf() / acosl() ----求反余弦值
acosh() / acoshf() / acoshl() ----求反雙曲余弦值
atan() / atanf() / atanl() ----求反正切值
atan2() / atan2f() / atan2l() ----求坐標值的反正切值
atanh() / atanhf() / atanhl() ----求反雙曲正切值
Math Functions(數學函數)
/************************************************************
* *
* Math Functions(數學函數) *
* *
***********************************************************/
#pragma mark --- 三角函數 a前綴表示取反 asin反三角函數
//TODO: 求反余弦值
extern float acosf(float);
extern double acos(double);
extern long double acosl(long double);
//TODO: 求反正弦值
extern float asinf(float);
extern double asin(double);
extern long double asinl(long double);
//TODO: 求反正切值
extern float atanf(float);
extern double atan(double);
extern long double atanl(long double);
//TODO: 求坐標值的反正切值
extern float atan2f(float, float);
extern double atan2(double, double);
extern long double atan2l(long double, long double);
//TODO: 求余弦值
extern float cosf(float);
extern double cos(double);
extern long double cosl(long double);
//TODO: 求正弦值
extern float sinf(float);
extern double sin(double);
extern long double sinl(long double);
//TODO: 求正切值
extern float tanf(float);
extern double tan(double);
extern long double tanl(long double);
//TODO: 求反雙曲余弦值
extern float acoshf(float);
extern double acosh(double);
extern long double acoshl(long double);
//TODO: 求反雙曲正弦值
extern float asinhf(float);
extern double asinh(double);
extern long double asinhl(long double);
//TODO: 求反雙曲正切值
extern float atanhf(float);
extern double atanh(double);
extern long double atanhl(long double);
//TODO: 求雙曲余弦值
extern float coshf(float);
extern double cosh(double);
extern long double coshl(long double);
//TODO: 求雙曲正弦值
extern float sinhf(float);
extern double sinh(double);
extern long double sinhl(long double);
//TODO: 求雙曲正切值
extern float tanhf(float);
extern double tanh(double);
extern long double tanhl(long double);
//TODO: 求取自然數e的冪
extern float expf(float);
extern double exp(double);
extern long double expl(long double);
//TODO: 計算參數以 2 為底的指數
extern float exp2f(float);
extern double exp2(double);
extern long double exp2l(long double);
//TODO: 計算基礎 e 指數參數盅蝗,但不包括 1
extern float expm1f(float);
extern double expm1(double);
extern long double expm1l(long double);
//TODO: 以e為底的對數(log10f則為10為底肚邢、log2f:2為底 )
extern float logf(float);
extern double log(double);
extern long double logl(long double);
extern float log10f(float);//以10為底的對數
extern double log10(double);
extern long double log10l(long double);
extern float log2f(float);//以2為底的對數
extern double log2(double);
extern long double log2l(long double);
//TODO: 計算基礎 e 對數 1 加上參數
extern float log1pf(float);
extern double log1p(double);
extern long double log1pl(long double);
//TODO: 提取 _X 指數,作為一個帶符號整數值為浮點格式
extern float logbf(float);
extern double logb(double);
extern long double logbl(long double);
//TODO: 浮點數分解為整數和小數。返回 _X 的有符號的小數部分
extern float modff(float, float *);
extern double modf(double, double *);
extern long double modfl(long double, long double *);
//TODO: 計算從尾數和指數的一個實數
extern float ldexpf(float, int);
extern double ldexp(double, int);
extern long double ldexpl(long double, int);
//TODO: 浮點數分解尾數和二為底的指數
extern float frexpf(float, int *);
extern double frexp(double, int *);
extern long double frexpl(long double, int *);
//TODO: 提取_X 指數為無符號整型值
extern int ilogbf(float);
extern int ilogb(double);
extern int ilogbl(long double);
//TODO: 以 FLT_RADIX乘以_X到乘冪運算_Y
extern float scalbnf(float, int);
extern double scalbn(double, int);
extern long double scalbnl(long double, int);
//TODO: 將浮點數乘以 FLT_RADIX 的整數冪飒房。
extern float scalblnf(float, long int);
extern double scalbln(double, long int);
extern long double scalblnl(long double, long int);
//TODO: 浮點數絕對值
extern float fabsf(float);
extern double fabs(double);
extern long double fabsl(long double);
//TODO: 計算參數的實立方根
extern float cbrtf(float);
extern double cbrt(double);
extern long double cbrtl(long double);
//TODO: 求值直角三角形的斜邊長度赢织,給出的兩邊為 x 和 y (換言之擎鸠,根的長度 x2 + y2)揭鳞。
extern float hypotf(float, float);
extern double hypot(double, double);
extern long double hypotl(long double, long double);
//TODO: 求n的m次方的值,計算以n為底數的m次冪
extern float powf(float, float);
extern double pow(double, double);
extern long double powl(long double, long double);
//TODO: 開平方
extern float sqrtf(float);
extern double sqrt(double);
extern long double sqrtl(long double);
//TODO: 函數返回 x 的高斯誤差函數
extern float erff(float);
extern double erf(double);
extern long double erfl(long double);
//https://msdn.microsoft.com/zh-cn/library/
//TODO: 函數返回 x 的補余高斯誤差函數炕贵。
extern float erfcf(float);
extern double erfc(double);
extern long double erfcl(long double);
lgammaf 數值計算函數
/* ===================
lgammaf, lgamma, and lgammal are not thread-safe. The thread-safe
variants lgammaf_r, lgamma_r, and lgammal_r are made available if
you define the _REENTRANT symbol before including <math.h>
====================== */
#pragma mark ---lgammaf...
//TODO: 計算伽瑪參數絕對值的自然對數
extern float lgammaf(float);
extern double lgamma(double);
extern long double lgammal(long double);
//TODO: 計算_X 的伽瑪函數
extern float tgammaf(float);
extern double tgamma(double);
extern long double tgammal(long double);
//TODO: 計算值的上限。向上取整 進1
extern float ceilf(float);
extern double ceil(double);
extern long double ceill(long double);
//TODO: 對參數向下取整野崇,返回參數的下限称开。
extern float floorf(float);
extern double floor(double);
extern long double floorl(long double);
//TODO: 通過使用當前舍入方向,舍入參數為浮點格式的一個整數值乓梨,整數鳖轰。返回舍入的整數值。
extern float nearbyintf(float);
extern double nearbyint(double);
extern long double nearbyintl(long double);
//TODO: 將浮點值舍入到最接近的整數(采用浮點格式)督禽,四舍五入函數
extern float rintf(float);
extern double rint(double);
extern long double rintl(long double);
//FIXME: 也是四舍五入
extern long int lrintf(float);
extern long int lrint(double);
extern long int lrintl(long double);
//TODO: 四舍五入法
extern float roundf(float);
extern double round(double);
extern long double roundl(long double);
//TODO: 四舍五入脆霎,取最接近的整數
extern long int lroundf(float);
extern long int lround(double);
extern long int lroundl(long double);
truncf截斷函數
#pragma mark ---truncf...
/* ======================
long long is not part of C90. Make sure you are passing -std=c99 or
-std=gnu99 or higher if you need these functions returning long longs
====================== */
//TODO: 截斷參數為整數部分,返回參數的整數部分
extern float truncf(float);
extern double trunc(double);
extern long double truncl(long double);
//TODO: 求兩數整除后的余數
extern float fmodf(float, float);
extern double fmod(double, double);
extern long double fmodl(long double, long double);
//TODO: 計算余數 _X 除 _Y
extern float remainderf(float, float);
extern double remainder(double, double);
extern long double remainderl(long double, long double);
//TODO: 計算第一個指定參數除以第二個指定參數的余數狈惫。也要計算出第一指定參數的有效位數除以第二指定參數的有效位數的商睛蛛,然后使用在第三參數中指定的位置返回該商。
extern float remquof(float, float, int *);
extern double remquo(double, double, int *);
extern long double remquol(long double, long double, int *);
//TODO: 用_X的大小和_Y的符號來返回值
extern float copysignf(float, float);
extern double copysign(double, double);
extern long double copysignl(long double, long double);
//TODO: 用_X中指示的內容返回清掃NaN胧谈,
extern float nanf(const char *);
extern double nan(const char *);
extern long double nanl(const char *);
extern float nextafterf(float, float);
extern double nextafter(double, double);
extern long double nextafterl(long double, long double);
extern double nexttoward(double, long double);
extern float nexttowardf(float, long double);
extern long double nexttowardl(long double, long double);
//TODO: 計算參數之間的正整數差異忆肾。(如果 _X 比 _Y 大,_X 和 _Y 之間的差異菱肖;否則客冈,+0。)
extern float fdimf(float, float);
extern double fdim(double, double);
extern long double fdiml(long double, long double);
//TODO: 求最大值
extern float fmaxf(float, float);
extern double fmax(double, double);
extern long double fmaxl(long double, long double);
//TODO: 求最小值
extern float fminf(float, float);
extern double fmin(double, double);
extern long double fminl(long double, long double);
//TODO: 計算第一個和第二個指定的參數的產品稳强,然后將第三個指定的參數添加到結果场仲;整個計算是作為單個操作執(zhí)行的。表達式 (_X x _Y) + _Z 的結果退疫。整個計算都作為單個操作執(zhí)行渠缕,即子表達式計算到無限精度并且僅對最終結果四舍五入。
extern float fmaf(float, float, float);
extern double fma(double, double, double);
extern long double fmal(long double, long double, long double);
轉載