-
Notifications
You must be signed in to change notification settings - Fork 0
Value forms: Novika's numbers, strings, booleans, words, and builtins
Alexey Yurchenko edited this page Aug 28, 2022
·
3 revisions
- Novika numbers are called decimals. They represent numbers in the decimal (base-10) number system.
- Novika numbers can be arbitrarily large.
- Novika numbers have arbitrary precision.
-
Without sign:
0
,9
,12345
. -
Negative decimal:
-1
,-0
,-12345
. -
Explicitly positive decimal:
+1
,+0
,+12345
. -
Float decimals:
1.234
,0.005
,0.0
,0.0000
-
Negative float decimals:
-1.234
,-0.0
, etc. -
Explicitly positive float decimals:
+1.234
,+0.0
, etc.
Underscores are allowed in the middle of the numeric parts. Leading, trailing underscores are disallowed (your number will be interpreted as a word). Underscores before and after .
are disallowed (100_.5
will be interpreted as 100_ . 5
, e.g. word 100_
followed by word .
followed by decimal 5
; similarly after .
)
- Builtin
decimal?
can be used to check whether a form is a decimal:1 decimal?
leavestrue
,'foo' decimal?
leavesfalse
.
Note: this list may be outdated. Explore the system to learn more.
-
+
leaves the sum of two decimals:1 2 +
leaves3
on the active stack. -
-
leaves the difference of two decimals:1 2 -
leaves-1
on the active stack. -
*
leaves the product of two decimals:2 4 *
leaves8
on the active stack. -
/
divides two decimals4 2 /
leaves2
on the active stack,2 4 /
leaves0.5
on the active stack. -
rem
leaves the remainder from dividing two decimals:2 4 rem
leaves2
,4 2 rem
leaves0
. -
/?
checks for divisibility (whether remainder is zero):2 4 /?
leavesfalse
, and4 2 /?
leaves true. - Comparison words
<
(less than),>
(more than),<=
(less than or equal to),>=
(more than or equal to) operate on decimals. -
rand
leaves a pseudo-random decimal between 0-1 on the active stack.
TODO?