A collection of common operations on integer numbers.
Most operations make no assumption on the precision of integers.
Operation bitNot
is necessarily an exception.
Author: Sergio Antoy
Version: October 2016
(^)
:: Int -> Int -> Int
The value of a ^ b
is a
raised to the power of b .
|
pow
:: Int -> Int -> Int
The value of pow a b
is a
raised to the power of b .
|
ilog
:: Int -> Int
The value of ilog n
is the floor of the logarithm
in the base 10 of n .
|
isqrt
:: Int -> Int
The value of isqrt n
is the floor
of the square root of n .
|
factorial
:: Int -> Int
The value of factorial n
is the factorial of n .
|
binomial
:: Int -> Int -> Int
The value of binomial n m
is n*(n-1)*...*(n-m+1)/m*(m-1)*...1 .
|
max3
:: Ord a => a -> a -> a -> a
Returns the maximum of the three arguments. |
min3
:: Ord a => a -> a -> a -> a
Returns the minimum of the three arguments. |
maxlist
:: Ord a => [a] -> a
Returns the maximum of a list of integer values. |
minlist
:: Ord a => [a] -> a
Returns the minimum of a list of integer values. |
bitTrunc
:: Int -> Int -> Int
The value of bitTrunc n m
is the value of the n
least significant bits of m .
|
bitAnd
:: Int -> Int -> Int
Returns the bitwise AND of the two arguments. |
bitOr
:: Int -> Int -> Int
Returns the bitwise inclusive OR of the two arguments. |
bitNot
:: Int -> Int
Returns the bitwise NOT of the argument. |
bitXor
:: Int -> Int -> Int
Returns the bitwise exclusive OR of the two arguments. |
even
:: Int -> Bool
Returns whether an integer is even |
odd
:: Int -> Bool
Returns whether an integer is odd |
The value of
|
The value of
|
The value of
|
The value of
|
The value of
|
The value of
|
Returns the maximum of the three arguments.
|
Returns the minimum of the three arguments.
|
Returns the maximum of a list of integer values. Fails if the list is empty.
|
Returns the minimum of a list of integer values. Fails if the list is empty.
|
The value of
|
Returns the bitwise AND of the two arguments.
|
Returns the bitwise inclusive OR of the two arguments.
|
Returns the bitwise NOT of the argument. Since integers have unlimited precision, only the 32 least significant bits are computed.
|
Returns the bitwise exclusive OR of the two arguments.
|
Returns whether an integer is even
|
Returns whether an integer is odd
|