Return to the home page.

The Ultimate Windows Math Toolbox

 


bullet Ver 3.1.805
8 September 2008
bullet Free support
bullet Only $44.85 (US)
(Professional)
Click to buy UltimaCalc Professional
bullet Only $34.85 (US)
(Standard)
Click to buy UltimaCalc Standard.

bullet Free download

<<< Prev  Next >>>
Algebra - Introduction   

 

Integer Arithmetic

The following functions operate exclusively on integers. It is an error if any argument is not an integer, except where indicated.


iquot(num, denom)   and   irem(num, denom)

These functions return the quotient and remainder respectively when their first argument is divided by their second argument. For irem, the absolute value of the second number is used.

For example, iquot(30, 7) returns 4 and irem(30, 7) returns 2.
However, iquot(30, -7) returns -4 and irem(30, -7) returns 2.

The remainder is negative if the first number (the dividend) is negative, but the absolute value of the remainder is always less than the absolute value of the second argument (the divisor). In general, d*iquot(n, d) + irem(n, d) always evaluates to n when d is non-zero. See also mod.


idiv(num, denom)

This function returns a list of two items - the quotient and remainder obtained when the first argument (the divident) is divided by the second argument (the divisor). This is logically equivalent to (but not as efficient as) using iquot and irem and combining their results in a list.

The dividend, divisor, quotient and remainder are related by the formula: dividend = divisor * quotient + remainder with the remainder chosen so that it is of the same sign as the numerator, and smaller in magnitude than the magnitude of the denominator.
Examples:
idiv(30, 7) returns [4, 2]
idiv(30, -7) returns [-4, 2]
idiv(-30, 7) returns [-4, -2]
idiv(-30, -7) returns [4, -2]


floor(number)   and   ceil(number)

These are the 'floor' and 'ceiling' functions. If the argument is a fraction or a decimal number, 'floor' returns the largest integer that is not greater than its argument, and 'ceil' returns the smallest number that is not less than its argument. If the argument is an integer, the result will be that integer. With any other type of argument, this function does nothing.
Examples:
floor(30/7) returns 4
floor(-30/7) returns -5
ceil(30/7) returns 5
ceil(-30/7) returns -4
floor(3.9) returns 3
floor(-3.1) returns -4
ceil(3.1) returns 4
ceil(-3.9) returns -3
floor(a + b) returns floor(a + b) if the symbols a and b have not been given values.
ceil(1234 * pi) returns ceil(1234 * pi).


mod(n1, n2)

This is the modulo function. It returns the remainder after dividing the first number by the absolute value of the second number. The result is always non-negative, and less than the second argument. Compare with irem.

For example, mod(30, 7) returns 2
mod(-30, 7) returns 5
irem(-30, 7) returns -2


gcd(n1, n2)

This function return the greatest common divisor (GCD) of the absolute values of its two arguments. If one number is zero, the other number will be returned as the result. This function will also work on expressions.

For example, gcd(30, 25) returns 5 and gcd(0, 0) returns 0.


Factorials

The factorial of a non-negative integer is obtained by following it with an exclamation mark. If the argument is negative, or is not an integer, the expression is not altered.

For example, 5! returns 120 and 20! returns 2432902008176640000.
Also, (-5)! returns (-5)! and x! returns x!.


Roots

The function isqrt returns the largest number whose square is not greater than the value of the argument, which must be a non-negative integer. Compare this with the function sqrt which accepts an argument which need not be an integer. raises this argument to the power of 1/2, and tries to simplify the result.

For example, isqrt(121) and sqrt(121) both return 11
isqrt(120) returns 10 whereas sqrt(120) returns 2 * 30^(1/2).

The function irootn returns the largest number whose nth power is not greater in magnitude than the absolute value of the argument, which must be an integer. The argument may be negative if and only if the power is odd.

For example, irootn(1331, 3) and irootn(14641, 4) both return 11
irootn(-125, 3) returns -5 and irootn(-124, 3) returns -4.