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:
| Suffix | Factor | Examples |
|---|---|---|
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:
5mis 5,000,000 — not five metres. A metre requires a space:5 m.G,TandPare not scalar or money suffixes.1.5Gstrikes out the letterGas 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:
| Letter | Operator |
|---|---|
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):
| Prefix | Base | Digits |
|---|---|---|
0x | 16 | 0-9 A-F |
0b | 2 | 0 1 |
0o | 8 | 0-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 to0x7FFFFFFFFFFFFFFF(9223372036854775807) in every base:-0x7FFFFFFFFFFFFFFFis accepted, while-0x8000000000000000and0x8000000000000000exceed 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.
9223372036854775808becomes9.22e18. Exact integer handling applies only to base literals, theint/bin/oct/hexfunctions, and theas/in/to basephrases.
Base names and phrases
Base names are case-insensitive:
| Name | Base |
|---|---|
decimal, base10 | 10 |
binary, base2 | 2 |
octal, base8 | 8 |
hex, hexadecimal, base16 | 16 |
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.
| Operation | Meaning | Notes |
|---|---|---|
& | bitwise AND | |
| | bitwise OR | the glyph is always bitwise: boolean operands are an error (false | (1/0 > 0)) |
xor | bitwise XOR (word) | 6 xor 3 = 5 |
<< | left shift | shift 0…63; overflow is an error |
>> | right shift | shift 0…63; arithmetic for negative values |
/ | integer division | the result is a decimal number when there is a remainder |
% | remainder | |
^ | power | exponent 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.
Related
- Operators & logic — precedence and the full integer tables.
- Built-in functions —
int,bin,oct,hexand the other 19 functions. - Answer tokens — how a base representation survives a token.