This chapter presents a complete reference on wfroth.
Last update: |
2-January-1999 |
State (estimation) |
100% |
This chapter includes the following sections:
Integer arithmetic is performed with a 32-bits precision. Nevertheless, some operations are calculated in 64-bits for intermediate calculations (*/ and */MOD), but the result is still in 32-bits.
Attempt to divide by value zero leads to a run-time error: program is gracefully stopped. Note that */MOD can bring the error "Divide by zero" even if the divisor is not zero: this is the case when the resulting quotient is too large to fit into the 32-bit register.
Value range:
Unsigned 32-bits integer |
0 |
to |
4,294,967,295 |
Signed 32-bits integer |
-2,147,483,648 |
to |
2,147,483,647 |
You must remember that signed and unsigned acts only for the interpretation of integers. A same binary value can be interpreted as signed or unsigned. It depends of the operation you apply on it (U< vs < for example).
NEGATE |
( n1 --- n2 ) |
n2 = -n1 |
Negate the given integer (ie 3 -> -3).
+ |
( n1 n2 --- n3 ) |
n3 = n1 + n2 |
Add two integers.
- |
( n1 n2 --- n3 ) |
n3 = n1 - n2 |
Substract two integers.
: - negate + ;
* |
( n1 n2 --- n3 ) |
n3 = n1 * n2 |
Multiply two integers.
/ |
( n1 n2 --- n3 ) |
n3 = n1 / n2 |
Integer division of two integers.
/MOD |
( n1 n2 --- n3 n4 ) |
n3 = n1 % n2 |
|
n4 = n1 / n2 |
Integer division of two integers (remainder and quotient).
MOD |
( n1 n2 --- n3 ) |
n3 = n1 % n2 |
Integer division (remainder only) of two integers.
ABS |
( n1 --- n2 ) |
n2 = ABS( n1 ) |
Compute the absolute value for the top stack integer.
RND |
( n1 n2 --- n3 ) |
n3 = [n1..n2] |
Compute a pseudo-random integer between [n1..n2].
*/ |
( n1 n2 n3 --- n4 ) |
n4 = (n1 * n2) / n3 |
Intermediate calculations are made in 64-bits (double-precision). But the final result is in 32-bits.
*/MOD |
( n1 n2 n3 --- n4 n5 ) |
n4 = (n1 * n2) % n3 |
|
n5 = (n1 * n2) / n3 |
Intermediate calculations are made in 64-bits (double-precision). But the final result is in 32-bits.
FALSE |
( --- ff ) |
Alias: OFF |
|
ff = 0 |
TRUE |
( --- tf ) |
Alias: ON |
|
tf = -1 |
Logical values for true and false. A logical value has two values: false (ie zero integer value) or true (ie not zero integer value). By convention, true logical value will be integer value -1.
MIN |
( n1 n2 --- n3 ) |
n3 = min( n1, n2 ) |
MAX |
( n1 n2 --- n3 ) |
n3 = max( n1, n2 ) |
UMIN |
( u1 u2 --- u3 ) |
u3 = min( u1, u2 ) |
UMAX |
( u1 u2 --- u3 ) |
u3 = min( u1, u2 ) |
Return the greatest or lowest value of two signed or unsigned integers.
== |
( n1 n2 --- f ) |
Alias: = |
|
f = (n1==n1) ? TRUE : FALSE |
!= |
( n1 n2 --- f ) |
Alias: <> |
|
f = (n1!=n1) ? TRUE : FALSE |
< |
( n1 n2 --- f ) |
|
|
f = (n1<n1) ? TRUE : FALSE |
<= |
( n1 n2 --- f ) |
|
|
f = (n1<=n1) ? TRUE : FALSE |
> |
( n1 n2 --- f ) |
|
|
f = (n1>n1) ? TRUE : FALSE |
>= |
( n1 n2 --- f ) |
|
|
f = (n1>=n1) ? TRUE : FALSE |
U< |
( u1 u2 --- f ) |
|
|
f = (u1<u1) ? TRUE : FALSE |
U<= |
( u1 u2 --- f ) |
|
|
f = (u1<=u1) ? TRUE : FALSE |
U> |
( u1 u2 --- f ) |
|
|
f = (u1>u1) ? TRUE : FALSE |
U>= |
( u1 u2 --- f ) |
|
|
f = (u1>=u1) ? TRUE : FALSE |
Compare two signed or unsigned integers.
NOT |
( n --- f ) |
Alias: 0= |
|
Alias: 0== |
|
f = (!n) ? TRUE : FALSE |
Perform the logical operation.
0< |
( n --- f ) |
f = (n < 0) ? TRUE : FALSE |
0<= |
( n --- f ) |
f = (n <= 0) ? TRUE : FALSE |
0> |
( n --- f ) |
f = (n > 0) ? TRUE : FALSE |
0>= |
( n --- f ) |
f = (n >= 0) ? TRUE : FALSE |
Compare a signed integer with 0.
[WITHIN] |
( n1 n2 n3 --- f ) |
f = (n1>=n2 && n1<=n3) ? TRUE : FALSE |
[WITHIN[ |
( n1 n2 n3 --- f ) |
f = (n1>=n2 && n1<n3) ? TRUE : FALSE |
]WITHIN] |
( n1 n2 n3 --- f ) |
f = (n1>n2 && n1<=n3) ? TRUE : FALSE |
]WITHIN[ |
( n1 n2 n3 --- f ) |
f = (n1>n2 && n1<n3) ? TRUE : FALSE |
[UWITHIN] |
( u1 u2 u3 --- f ) |
f = (u1>=u2 && u1<=u3) ? TRUE : FALSE |
[UWITHIN[ |
( u1 u2 u3 --- f ) |
f = (u1>=u2 && u1<u3) ? TRUE : FALSE |
]UWITHIN] |
( u1 u2 u3 --- f ) |
f = (u1>u2 && u1<=u3) ? TRUE : FALSE |
]UWITHIN[ |
( u1 u2 u3 --- f ) |
f = (u1>u2 && u1<u3) ? TRUE : FALSE |
Compare a signed or unsigned integer within two others values.
AND |
( n1 n2 --- n3 ) |
n3 = n1 & n2 |
OR |
( n1 n2 --- n3 ) |
n3 = n1 | n2 |
XOR |
( n1 n2 --- n3 ) |
n3 = n1 ^ n2 |
SHL |
( n1 n2 --- n3 ) |
n3 = n1 << n2 |
SHR |
( n1 n2 --- n3 ) |
n3 = n1 >> n2 |
Compute the logical bit operations.