More Math Words

Here are some useful built-in words for common mathematical functions. You may skip this section, but use it as a reference later.
WordAction
FLOOR

Displays the floor of a number, which is the closest integer lower than the given number.

CEIL

Displays the ceiling of a number, which is the closest integer higher than the given number.

ROUND

Rounds off a real.

MIN

Minimum of a two numbers.

MAX

Maximum of a two numbers.

^

Exponentiation

2 3 ^ 
becomes
8

TAN
SIN
COS

Usual trigonometric functions.

ATAN2

The special arctangent, very useful for computing directions from vectors. A definition may be found here: Wikipedia: Atan2

#e
#pi

Constant values of e and π.

EXP
LN

Natural exponentiation and natural logarithms.

LOG10

Logarithms base 10.

TO-DEG
TO-RADIANS

Converts angles to degrees or radians.

MOD
FMOD

Integer modulus and real modulus. Use FMOD if either operand is a real number.

ABS

The absolute value.

Logical Operators

WordAction
TRUE

Puts the logical value

true
on the stack.

FALSE

Puts the logical value

false
on the stack.

OR

Logical or. For example,

true 1 2 = OR
becomes
true
.

AND

Logical and. For example,

true 1 2 = AND
becomes
false
.

Quiz

Question 1


		Use words you learnt to find the truncation part of a number. For example, 
5.25 your code here .
should display
5.0
.

Question 2

 There is a built-in word 
DUP
that duplicates the top of the stack. For example,
5.25 DUP
ends up with
5.25 5.25
on the stack.
Use
DUP
and words you learnt to find the fractional part of a number. For example,
5.25 your code here .
should display
0.25
.

Question 3

Do your solutions work for negative numbers?



Next: Main Menu