关于MFC中取绝对值的函数——abs()和fabs()

   

#include "stdio.h" #include "math.h" main() { float i,j,k1,k3; i=-1.02; k1=abs(i); j=-2.03; k3=fabs(j); printf("abs=%.2f/nfabs=%.2f/n",k1,k3); }

输出结果:k1=1.00,k3=2.03。

可见abs是取绝对值后再取整,而fabs是取绝对值。vc中对fabs()定义有3种:float fabs(),double fabs(),long double fabs()

 

MFC中的取绝对值函数

nline long double fabsl(long double _X) {return (fabs((double)_X)); } inline float fabsf(float _X) {return ((float)fabs((double)_X)); }

 

MFC中其他的操作函数

 

inline long double acosl(long double _X) {return (acos((double)_X)); } inline long double asinl(long double _X) {return (asin((double)_X)); } inline long double atanl(long double _X) {return (atan((double)_X)); } inline long double atan2l(long double _X, long double _Y) {return (atan2((double)_X, (double)_Y)); } inline long double ceill(long double _X) {return (ceil((double)_X)); } inline long double cosl(long double _X) {return (cos((double)_X)); } inline long double coshl(long double _X) {return (cosh((double)_X)); } inline long double expl(long double _X) {return (exp((double)_X)); } inline long double fabsl(long double _X) {return (fabs((double)_X)); } inline long double floorl(long double _X) {return (floor((double)_X)); } inline long double fmodl(long double _X, long double _Y) {return (fmod((double)_X, (double)_Y)); } inline long double frexpl(long double _X, int *_Y) {return (frexp((double)_X, _Y)); } inline long double ldexpl(long double _X, int _Y) {return (ldexp((double)_X, _Y)); } inline long double logl(long double _X) {return (log((double)_X)); } inline long double log10l(long double _X) {return (log10((double)_X)); } inline long double modfl(long double _X, long double *_Y) {double _Di, _Df = modf((double)_X, &_Di); *_Y = (long double)_Di; return (_Df); } inline long double powl(long double _X, long double _Y) {return (pow((double)_X, (double)_Y)); } inline long double sinl(long double _X) {return (sin((double)_X)); } inline long double sinhl(long double _X) {return (sinh((double)_X)); } inline long double sqrtl(long double _X) {return (sqrt((double)_X)); } inline long double tanl(long double _X) {return (tan((double)_X)); } inline long double tanhl(long double _X) {return (tanh((double)_X)); } inline float frexpf(float _X, int *_Y) {return ((float)frexp((double)_X, _Y)); } inline float ldexpf(float _X, int _Y) {return ((float)ldexp((double)_X, _Y)); } #if !defined(_M_MRX000) && !defined(_M_ALPHA) inline float acosf(float _X) {return ((float)acos((double)_X)); } inline float asinf(float _X) {return ((float)asin((double)_X)); } inline float atanf(float _X) {return ((float)atan((double)_X)); } inline float atan2f(float _X, float _Y) {return ((float)atan2((double)_X, (double)_Y)); } inline float ceilf(float _X) {return ((float)ceil((double)_X)); } inline float cosf(float _X) {return ((float)cos((double)_X)); } inline float coshf(float _X) {return ((float)cosh((double)_X)); } inline float expf(float _X) {return ((float)exp((double)_X)); } inline float fabsf(float _X) {return ((float)fabs((double)_X)); } inline float floorf(float _X) {return ((float)floor((double)_X)); } inline float fmodf(float _X, float _Y) {return ((float)fmod((double)_X, (double)_Y)); } inline float logf(float _X) {return ((float)log((double)_X)); } inline float log10f(float _X) {return ((float)log10((double)_X)); } inline float modff(float _X, float *_Y) { double _Di, _Df = modf((double)_X, &_Di); *_Y = (float)_Di; return ((float)_Df); } inline float powf(float _X, float _Y) {return ((float)pow((double)_X, (double)_Y)); } inline float sinf(float _X) {return ((float)sin((double)_X)); } inline float sinhf(float _X) {return ((float)sinh((double)_X)); } inline float sqrtf(float _X) {return ((float)sqrt((double)_X)); } inline float tanf(float _X) {return ((float)tan((double)_X)); } inline float tanhf(float _X) {return ((float)tanh((double)_X)); }

你可能感兴趣的:(VC++)