Numlex Documentation
Syntax Reference
Report issue

Numbers & integer bases

Decimal, grouped, scientific and compact literals, quick operators, and exact integer bases (hex, binary, octal).

Numlex accepts numbers the way people write them — grouped thousands, scientific notation, compact suffixes like 1.5M — and also the exact integer forms 0x, 0b and 0o.

This page documents the literal forms themselves, the compact-suffix ambiguities worth knowing (5m is five million, not five metres), the optional quick operators, integer bases with their display and overflow rules, and a full example set.

Decimal literals

  • The decimal separator is . or , depending on the regional format — see Number formats & result display.
  • Thousands separators in input are normalized: 1,234 → 1234, 1 234 (format-dependent). Inside function calls a comma can instead separate arguments — see Built-in functions.
  • Scientific notation: 1.5e6, 2E-3.
  • Spaces around operators are arbitrary; parentheses ( ) group; unary + and - are allowed.

Compact suffixes

Compact suffixes sit immediately after the number, with no space, and apply to scalars and money sums:

SuffixFactorExamples
k / K×10³1.5k = 1,500; $2.5k = $2,500
m / M×10⁶1.5M = 1,500,000; $2.5M = $2,500,000

Two things worth knowing:

  • 5m is 5,000,000 — not five metres. A metre requires a space: 5 m.
  • G, T and P are not scalar or money suffixes. 1.5G strikes out the letter G as an unknown word and returns 1.5. Giga and tera exist only as catalog unit names used with a space: 2 Gm, 2 Gb, 2 Gbyte.

Quick operators (setting)

With the Quick operators setting enabled, four letters act as operators only between two digits — they never work inside identifiers:

LetterOperator
p+
m−
x×
d÷

The literal 0x… is never turned into a multiplication.

Integer bases (exact)

Radix literals use a strict prefix; the prefix case does not matter (0X, 0B, 0O all work):

PrefixBaseDigits
0x160-9 A-F
0b20 1
0o80-7

Rules:

  • Underscores only between two digits: 0x1_0, 100_000. Double underscores, underscores at the edges, or underscores directly after the prefix are errors (0x_1F, 0x1F_).
  • Sign-magnitude: -0x10 = −16. The literal magnitude is limited to 0x7FFFFFFFFFFFFFFF (9223372036854775807) in every base: -0x7FFFFFFFFFFFFFFF is accepted, while -0x8000000000000000 and 0x8000000000000000 exceed the exact-integer maximum and are errors. Digit overflow (0x10000000000000000) is also an error.
  • Display: non-negative results display in the base of the expression (0x1F + 1 → 0x20). Negative results, and operations that leave the exact integer domain (division with a remainder, ^ with a negative exponent), display in decimal (-0x10 → −16).
  • Plain decimal digit chains are not exact integers. 9223372036854775808 becomes 9.22e18. Exact integer handling applies only to base literals, the int/bin/oct/hex functions, and the as / in / to base phrases.

Base names and phrases

Base names are case-insensitive:

NameBase
decimal, base1010
binary, base22
octal, base88
hex, hexadecimal, base1616
base 2 / base 8 / base 10 / base 16 (space-separated integer)2 / 8 / 10 / 16
<expr> as <base name>          255 as hex            → 0xFF
<expr> in <base name>          99 in binary          → 0b1100011
<expr> to base 8               64 to base 8          → 0o100

Bitwise operations

The exact-integer mode is entered by 0x/0b/0o literals, by int(/bin(/oct(/hex( calls, by … as|in <base> and … to base N phrases, and by the bitwise glyphs & | << >> or the word xor (glyphs count only when the line has mathematical content — fish & chips stays prose). The words and/or behave as bitwise operators only when both sides are integers.

OperationMeaningNotes
&bitwise AND
|bitwise ORthe glyph is always bitwise: boolean operands are an error (false | (1/0 > 0))
xorbitwise XOR (word)6 xor 3 = 5
<<left shiftshift 0…63; overflow is an error
>>right shiftshift 0…63; arithmetic for negative values
/integer divisionthe result is a decimal number when there is a remainder
%remainder
^powerexponent is checked; a negative exponent produces a decimal number

All values here are exact integers: 0x7FFFFFFFFFFFFFFF = 9223372036854775807, and overflow is a visible error — never wraparound, never a silently rounded number. The words and/or/xor are contextual: two integers make them bitwise, two booleans make and/or logical, and mixing types in one operator is a strict error. Use explicit parentheses at boundaries.

The complete operator precedence is documented in Operators & logic.

Examples

0x1F + 1              → 0x20
0x1F in decimal       → 31
0b101101 + 1          → 0b101110
0o55 + 1              → 0o56
0x1_0                 → 0x10
100_000 as hex        → 0x186A0
256 as hex            → 0x100
16 in binary          → 0b10000
-0x10                 → -16
1 << 4                → 16
32 >> 2               → 8
0xFF & 0x0F           → 0x0F
5 | 2                 → 7
6 xor 3               → 5
5 << 3                → 40
(5 << 3) / 2          → 20

x = 0x1F
x & 1                 → 1
x + 1                 → 0x20
x as hex              → 0x1F

The last four lines run on one sheet, with x declared once.

Found an issue in these docs? Report it on GitHub