Next Previous Contents

4. Arithmetic commands

4.1 The + command

This command adds two numbers.

Examples:

> 12.5
[ 1]                      12.5
> 3.7
[ 2]                      12.5
[ 1]                       3.7
> +
[ 1]                      16.2
> (1, 3) (-2 4)
[ 3]                      16.2
[ 2]                     (1,3)
[ 1]                    (-2,4)
> +
[ 2]                      16.2
[ 1]                    (-1,7)

4.2 The - command

This command subtracts two numbers.

Examples:

> 15.7 3.2
[ 2]                      15.7
[ 1]                       3.2
> -
[ 1]                      12.5
> (4 -3) (1 -1)
[ 3]                      12.5
[ 2]                    (4,-3)
[ 1]                    (1,-1)
> -
[ 2]                      12.5
[ 1]                    (3,-2)

4.3 The * command

This command multiplies two numbers.

Examples:

> 3.4 -5.2 *
[ 1]                    -17.68
> (4, 2) (3 -1) *
[ 2]                    -17.68
[ 1]                    (14,2)

4.4 The / command

This command divides two numbers.

Examples:

> 10 3 /
[ 1]          3.33333333333333
> (4 8) (2 2)
[ 3]          3.33333333333333
[ 2]                     (4,8)
[ 1]                     (2,2)
> /
[ 2]          3.33333333333333
[ 1]                     (3,1)

4.5 The inv command

This command returns one divided by a number.

Examples:

> 5 inv
[ 1]                       0.2
> (4 2)
[ 2]                       0.2
[ 1]                     (4,2)
> inv
[ 2]                       0.2
[ 1]                (0.2,-0.1)

4.6 The mod command

This command returns the remainder of the division of y (level two) and x (level one).

Example:

> 10 3 mod
[ 1]                         1

4.7 The chs and neg commands

Thesse commands change the sign of a number.

Examples:

> 4
[ 1]                         4
> chs
[ 1]                        -4
> neg
[ 1]                         4

4.8 The abs command

This command returns the absolute value of a number. For real numbers, this is equal to the number without its sign. For complex number, it is the square root of the sum of the squares of the real and imaginary parts.

Examples:

> 4 abs
[ 1]                         4
> -5 abs
[ 2]                         4
[ 1]                         5
> (3 4)
[ 3]                         4
[ 2]                         5
[ 1]                     (3,4)
> abs
[ 3]                         4
[ 2]                         5
[ 1]                         5

4.9 The ceil command

This command returns the smallest integer greater than or equal to its input.

Examples:

> 3.9 ceil
[ 1]                         4
> -3.9 ceil
[ 2]                         4
[ 1]                        -3

4.10 The floor command

This command returns the greatest integer less than or equal to its input.

Examples:

> 3.9 floor
[ 1]                         3
> -3.9 floor
[ 2]                         3
[ 1]                        -4

4.11 The ip command

This command returns the integer part of its input.

Examples:

> pi
[ 1]          3.14159265358979
> ip
[ 1]                         3

4.12 The fp command

This command returns the fractional part of its input.

Examples:

> pi
[ 1]          3.14159265358979
> fp
[ 1]         0.141592653589793

4.13 The %of command

This command returns y (level two) percent of x (level one).

Examples:

> 200 25 %of
[ 1]                        50
> 314 13.9 %of
[ 2]                        50
[ 1]                    43.646

4.14 The %t command

This command returns the percent of the level two argument that is represented by the level one argument.

Examples:

> 200 25 %t
[ 1]                      12.5
> 520 52 %t
[ 2]                      12.5
[ 1]                        10

4.15 The %ch command

This command returns the percentage change from y (level two) to x (level 1) as a percentage of y.

Examples:

> 150 175 %ch
[ 1]          16.6666666666667
> 215 190 %ch
[ 2]          16.6666666666667
[ 1]         -11.6279069767442

4.16 The gcd command

This command returns the greatest common divisor of two numbers.

Examples:

> 411056775237 61754894058 gcd
[ 1]                      1257
> 895324789 3745907 gcd
[ 2]                      1257
[ 1]                         1

4.17 The lcm command

This command returns the least common multiple of two numbers.

Examples:

> 799984123 239874 lcm
[ 1]           191895391520502
> 104890 2349002 lcm
[ 2]           191895391520502
[ 1]              123193409890


Next Previous Contents