MDK::Common::Math

Section: User Contributed Perl Documentation (3)
Updated: 2014-01-24
Page Index
 

NAME

MDK::Common::Math - miscellaneous math functions  

SYNOPSIS

    use MDK::Common::Math qw(:all);

 

EXPORTS

$PI
the well-known constant
even(INT)
odd(INT)
is the number even or odd?
sqr(FLOAT)
sqr(3) gives 9
sign(FLOAT)
returns a value in { -1, 0, 1 }
round(FLOAT)
"round(1.2)" gives 1, "round(1.6)" gives 2
round_up(FLOAT, INT)
returns the number rounded up to the modulo: "round_up(11,10)" gives 20
round_down(FLOAT, INT)
returns the number rounded down to the modulo: "round_down(11,10)" gives 10
divide(INT, INT)
integer division (which is lacking in perl). In array context, also returns the remainder: "($a, $b) = divide(10,3)" gives "$a is 3" and "$b is 1"
min(LIST)
max(LIST)
returns the minimum/maximum number in the list
or_(LIST)
is there a true value in the list?
and_(LIST)
are all values true in the list?
sum(LIST)
product(LIST)
returns the sum/product of all the element in the list
factorial(INT)
factorial(4) gives 24 (4*3*2)
 

OTHER

the following functions are provided, but not exported:
factorize(INT)
"factorize(40)" gives "([2,3], [5,1])" as 40 = 2^3 + 5^1
decimal2fraction(FLOAT)
"decimal2fraction(1.3333333333)" gives "(4, 3)" ($PRECISION is used to decide which precision to use)
poly2(a,b,c)
Solves the a*x2+b*x+c=0 polynomial: "poly2(1,0,-1)" gives "(1, -1)"
permutations(n,p)
A(n,p)
combinaisons(n,p)
C(n,p)
 

SEE ALSO

MDK::Common


 

Index

NAME
SYNOPSIS
EXPORTS
OTHER
SEE ALSO