Perl Math Functions
by Geethalakshmi[ Edit ] 2010-09-17 12:25:51
Perl Math Functions
atan2(Y,X)
Returns the arctangent of Y/X in the range
cos(EXPR)
cos EXPR
cos
Returns the cosine of EXPR (expressed in radians). If EXPR is omitted takes cosine of `$_'.
exp(EXPR)
exp EXPR
exp
Returns `e' to the power of EXPR. If EXPR is omitted, gives exp($_).
hex(EXPR)
hex EXPR
hex
Returns the decimal value of EXPR interpreted as an hex string. (To interpret strings that might start with `0' or `0x' see oct().) If EXPR is omitted, uses `$_'.
int(EXPR)
int EXPR
int
Returns the integer portion of EXPR. If EXPR is omitted, uses `$_'.
log(EXPR)
log EXPR
log
Returns logarithm (base `e') of EXPR. If EXPR is omitted, returns log of `$_'.
oct(EXPR)
oct EXPR
oct
Returns the decimal value of EXPR interpreted as an octal string. (If EXPR happens to start off with `0x', interprets it as a hex string instead.) The following will handle decimal, octal and hex in the standard notation:
$val = oct($val) if $val =~ /^0/;
If EXPR is omitted, uses `$_'.
sin(EXPR)
sin EXPR
sin
Returns the sine of EXPR (expressed in radians). If EXPR is omitted, returns sine of `$_'.
sqrt(EXPR)
sqrt EXPR
sqrt
Return the square root of EXPR. If EXPR is omitted, returns square root of `$_'.