Most math functions accept infinity, negative infinity, and NaN values as input. In general, a NaN value as input results in a NaN value as output, and infinity values as input usually result in infinity values. If the input value is outside the domain or range of the function, errno is set to EDOM or ERANGE, respectively.
The following tables display the results of each math function when NaN or infinity values are input, and the associated errno value if one exists. The first table lists the functions that take only one argument; the second lists those that take two arguments.
Note: In some cases, infinity is always a valid input value for the function regardless of the language level (for example, atan). These cases do not appear in these two tables.
The functions in the following table take two arguments. The results from
NaN and infinity values vary depending on which argument they are passed
as. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
³ Function ³ Argument 1 ³ Argument 2 ³ Result ³ errno Value ³
ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
³ atan2 ³ NaN ³ any number ³ NaN ³ EDOM ³
³ ³ any number ³ NaN ³ NaN ³ ³
ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
³ fmod ³ NaN ³ any number ³ NaN ³ EDOM ³
³ ³ any number ³ NaN ³ NaN ³ EDOM ³
³ ³ ñinfinity ³ any number ³ 0 ³ EDOM ³
ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
³ ldexp ³ infinity ³ any number ³ infinity ³ ERANGE ³
³ ³ -infinity ³ any number ³ -infinity ³ ERANGE ³
³ ³ NaN ³ any number ³ NaN ³ EDOM ³
ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
³ pow ³ ñinfinity ³ 0 ³ NaN ³ EDOM ³
³ ³ infinity ³ -infinity ³ NaN ³ EDOM ³
³ ³ -infinity ³ ñinfinity ³ NaN ³ EDOM ³
³ ³ -infinity ³ <-1 ³ NaN ³ EDOM ³
³ ³ -infinity ³ <1, >-1 ³ NaN ³ EDOM ³
³ ³ -infinity ³ >1 ³ NaN ³ EDOM ³
³ ³ NaN ³ any number ³ NaN ³ EDOM ³
³ ³ any number ³ NaN ³ NaN ³ EDOM ³
³ ³ <=0 ³ infinity ³ NaN ³ EDOM ³
³ ³ 1 ³ ñinfinity ³ NaN ³ EDOM ³
³ ³ ñinfinity ³ ñ1 ³ 0 ³ ERANGE ³
³ ³ >0, <1 ³ infinity ³ 0 ³ ERANGE ³
³ ³ >0, <1 ³ -infinity ³ infinity ³ ERANGE ³
ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
Note: If a signaling NaN is passed to a math function, the behavior is undefined.