Skip to content

Value forms: Novika's numbers, strings, booleans, words, and builtins

Alexey Yurchenko edited this page Aug 28, 2022 · 3 revisions

Numbers

Overview

  • 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.

Literal

  • 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 .)

Predicate

  • Builtin decimal? can be used to check whether a form is a decimal: 1 decimal? leaves true, 'foo' decimal? leaves false.

Words operating on decimals

Note: this list may be outdated. Explore the system to learn more.

  • + leaves the sum of two decimals: 1 2 + leaves 3 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 * leaves 8 on the active stack.
  • / divides two decimals 4 2 / leaves 2 on the active stack, 2 4 / leaves 0.5 on the active stack.
  • rem leaves the remainder from dividing two decimals: 2 4 rem leaves 2, 4 2 rem leaves 0.
  • /? checks for divisibility (whether remainder is zero): 2 4 /? leaves false, and 4 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?