Math.h in POSIX, ISO, and Visual Studio

This page compares the list of functions in the C math.h header across 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 kind j0, j1, and jn 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
log1pYNYN 2
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
Click to find out more about consulting for numerical computing

 

[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 if x is not a NaN. (See floating point exceptions.)

 

Other C++ resources