GNU Info

Info Node: (zsh.info)The zsh/mathfunc Module

(zsh.info)The zsh/mathfunc Module


Next: The zsh/parameter Module Prev: The zsh/mapfile Module Up: Zsh Modules
Enter node , (file) or (file)node

The zsh/mathfunc Module
=======================

The zsh/mathfunc module provides standard mathematical functions for
use when evaluating mathematical formulae.  The syntax agrees with
normal C and FORTRAN conventions, for example,

     (( f = sin(0.3) ))

assigns the sine of 0.3 to the parameter f.

Most functions take floating point arguments and return a floating point
value.  However, any necessary conversions from or to integer type will
be performed automatically by the shell.  Apart from atan with a second
argument and the abs, int and float functions, all functions behave as
noted in the manual page for the corresponding C function, except that
any arguments out of range for the function in question will be
detected by the shell and an error reported.

The following functions take a single floating point argument: acos,
acosh, asin, asinh, atan, atanh, cbrt, ceil, cos, cosh, erf, erfc, exp,
expm1, fabs, floor, gamma, j0, j1, lgamma, log, log10, log1p, logb,
sin, sinh, sqrt, tan, tanh, y0, y1.  The atan function can optionally
take a second argument, in which case it behaves like the C function
atan2.  The ilogb function takes a single floating point argument, but
returns an integer.

The function signgam takes no arguments, and returns an integer, which
is the C variable of the same name, as described in man page gamma(3).
Note that it is therefore only useful immediately after a call to gamma
or lgamma.  Note also that `signgam()' and `signgam' are distinct
expressions.

The following functions take two floating point arguments: copysign,
fmod, hypot, nextafter.

The following take an integer first argument and a floating point second
argument: jn, yn.

The following take a floating point first argument and an integer second
argument: ldexp, scalb.

The function abs does not convert the type of its single argument; it
returns the absolute value of either a floating point number or an
integer.  The functions float and int convert their arguments into a
floating point or integer value (by truncation) respectively.

Note that the C pow function is available in ordinary math evaluation
as the `**' operator and is not provided here.


automatically generated by info2www version 1.2.2.9