Pancode - Commands - Arithmetic

The following commands perform basic mathematical and bitwise operations. Many of these commands are subject to scalar extension and use a numerical modifier to enable binary extension. Note that the trigonometric commands have their own page.

Add (+)

Adds two numbers. Subject to scalar and binary extension. If given a numerical modifier of 0, this command pushes 0. If given ⚐ as its sole argument, this command pushes 0.

Subtract (-)

Subtracts two numbers. Subject to scalar and binary extension. With a numerical modifier of 1, this command returns the negative of its sole argument.

Multiply (×)

Multiplies two numbers. Subject to scalar and binary extension. With a numerical modifier of 0, pushes 1. If given ⚐ as its sole argument, this command pushes 1.

Divide (÷)

Divides two numbers. Subject to scalar and binary extension. With a numerical modifier of 1, this command returns the reciprocal of its argument.

Note that since Pancode uses IEEE floats, division by zero is not an error and will simply return either infinity, negative infinity, or NaN, as per the IEEE specification.

Power (*)

Raises its first argument to the power of its second. Subject to scalar and binary extension (binary extension associates to the right). If given a numerical modifier of 0, this command returns 1. If given ⚐ as its sole argument, this command pushes 1.

Exponent (ê)

Takes a single argument and returns the mathematical constant e raised to that power. Subject to scalar extension.

Natural Logarithm (🌳)

Takes a single argument and returns the natural logarithm of that argument. Subject to scalar extension.

Logarithm (🌳)

Takes two arguments and returns the logarithm of the first in the base of the second. Subject to scalar and binary extension.

Square Root ()

Takes a single argument and returns its square root. Subject to scalar extension.

Nth Root ()

Takes two arguments and returns the nth root of the first, where n is the second argument. Subject to scalar and binary extension.

Remainder (|)

Takes two arguments and returns the first argument modulo the second. Subject to scalar extension but not binary extension. The sign of the result shall match that of the divisor.

LCM ()

Takes two arguments and returns their least common multiple. Subject to scalar and binary extension. With a numerical modifier of 0 or a ⚐ argument, returns 1.

GCD ()

Takes two arguments and returns their greatest common divisor. Subject to scalar and binary extension. With a numerical modifier of 0 or a ⚐ argument, returns 0.

Negate (_)

Returns the negative of its argument. Subject to scalar extension.

Reciprocal ()

Returns the reciprocal of its argument. Subject to scalar extension.

Ceiling ()

Returns the least integer greater than or equal to its argument. Subject to scalar extension.

Floor ()

Returns the greatest integer less than or equal to its argument. Subject to scalar extension.

Absolute Value (A)

Returns the absolute value of its argument. Subject to scalar extension.

Signum (a)

Returns the sign of its argument. Subject to scalar extension.

Bitwise Conjunction ()

Takes two arguments and performs the bitwise-and operation on them. The two numbers are treated as being in two's complement form. The result is undefined if either number is not an integer. Subject to scalar and binary extension. Returns -1 with a numerical argument of 0 or a ⚐ argument.

Bitwise Disjunction ()

Takes two arguments and performs the bitwise-or operation on them. The two numbers are treated as being in two's complement form. The result is undefined if either number is not an integer. Subject to scalar and binary extension. Returns 0 with a numerical argument of 0 or a ⚐ argument.

Bitwise Exclusive Or ()

Takes two arguments and performs the bitwise-xor operation on them. The two numbers are treated as being in two's complement form. The result is undefined if either number is not an integer. Subject to scalar and binary extension. Returns 0 with a numerical argument of 0 or a ⚐ argument.

Bitwise Negate (¬)

Takes one argument and takes its bitwise negation. Subject to scalar extension.

Documentation Index