Math.h in POSIX, ISO, and Visual Studio

This page compares the list of functions in the C math.h headeracross four versions: ISO (ANSI) pre-1999, ISO post-1999, POSIX, and Microsoft Visual Studio.

The smallest list is the ISO standard prior to 1999. All other lists completely contain the original ISO standard.

The latest POSIX and ISO standards are essentially identical. The only difference is that the POSIX standard requires Bessel functions of the first kindj0,j1, andjn and Bessel functions of the second kind y0, y1, and yn.

Microsoft supports the older ISO standard and supports the Bessel functions mentioned above. Microsoft supports some of the functions added to the ISO standard in 1999. The Microsoft names for these new functions are the ISO names with an underscore prefix. The only minor exception is that the Microsoft function corresponding to the ISO function fpclassify is_fpclass rather than_fpclassify.

Details are given in the table below.

FunctionPOSIXold ISOISO C99MicrosoftNotes
acosYYYY 
acoshYNYN1
asinYYYY 
asinhYNYN1
atanYYYY 
atan2YYYY 
atanhYNYN1
cbrtYNYN 
ceilYYYY 
copysignYNYY_copysign
cosYYYY 
coshYYYY 
erfYNYN2
erfcYNYN 
expYYYY 
exp2YNYN 
expm1YNYN2
fabsYYYY 
fdimYNYN 
floorYYYY 
fmaYNYN 
fmaxYNYN 
fminYNYN 
fmodYYYY 
fpclassifyYNYY_fpclass
frexpYYYY 
hypotYNYY _hypot
ilogbYNYN 
isfiniteYNYN3
isgreaterYNYN 
isgreaterequalYNYN 
isinfYNYN 
islessYNYN 
islessequalYNYN 
islessgreaterYNYN 
isnanYNYY_isnan
isnormalYNYN 
isunorderedYNYN 
j0YNNY_j0
j1YNNY_j1
jnYNNY_jn
ldexpYYYY 
lgammaYNYN2
llrintYNYN 
llroundYNYN 
logYYYY 
log10YYYY 
log1pYNYN2
log2YNYN 
logbYNYY_logb
lrintYNYN 
lroundYNYN 
modfYYYY 
nanYNYN 
nearbyintYNYN 
nextafterYNYY_nextafter
nexttowardNNYN 
powYYYY 
remainderYNYN 
remquoYNYN 
rintYNYN 
roundYNYN 
scalblnYNYN 
scalbnNNYN 
signbitYNYN 
sinYYYY 
sinhYYYY 
sqrtYYYY 
tanYYYY 
tanhYYYY 
tgammaYNYN2
truncYNYN 
y0YNNY _y0
y1YNNY _y1
ynYNNY _yn

 

[1] The inverse hyperbolic functions can be reduced to more familiar functions.

  • asinh(x) = log(x + sqrt(x2 + 1))
  • acosh(x) = log(x + sqrt(x2 - 1))
  • atanh(x) = (log(1+x) - log(1-x))/2

[2] Here is stand-alone code for these functions:erf,expm1,log1p,lgamma,tgamma.

[3] You can test whether a number is a NaN by testing whether it equals itself. The expression(x == x) returns true if and only ifx is not a NaN. (Seefloating point exceptions.)

 


From John D. Cook's blog

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值