Nitpick Exotic Type Family
Nitpick provides deep support for advanced mathematical concepts beyond standard binary computation.
1. Ternary and Nonary Logic
For systems interfacing with optical computing or specific ML hardware, Nitpick provides types for Base-3 (Ternary) and Base-9 (Nonary) logic.
Balanced Ternary
(trit and tryte)
Instead of standard binary (0, 1), balanced ternary uses
three states: 1, 0, and
-1. * trit : A single balanced
ternary digit (-1, 0, 1). * tryte : Exactly 10
trits (representing 3^10 values).
Literals: trit and
tryte support two forms of literals depending
on the use-case: 1. Standard Decimal: For
general mathematical use, you can assign standard decimal
integers directly (e.g., -1). The compiler
translates this to ternary under the hood. 2.
Ternary Sequence Suffix (t,
tri, ter): For low-level
logic gating where the structural pattern of the trits
matters, you can write explicit ternary sequences. The
sequence uses 1, 0, and
T (where T represents -1). To
indicate a ternary literal, you must append t,
tri, or ter to the end of the
sequence.
// Standard decimal literal (simple value assignment)
trit:simple = -1;
tryte:block = 59048;
// Explicit ternary sequence using suffix (for bitmasking)
trit:logic_state = Tt; // Explicitly sets the trit to -1
tryte:mask = 1T0T1T0T1Tter; // Explicit pattern of 10 trits
Balanced Nonary
(nit and nyte)
Nonary logic uses Base-9, ranging from -4 to 4. *
nit : A single balanced nonary digit (-4, -3,
-2, -1, 0, 1, 2, 3, 4). * nyte : Exactly 5 nits
(representing 9^5 values).
Literals: Because explicit Base-9
sequence syntax is highly obscure, nit and
nyte only support standard decimal values.
nit:val = -4;
nyte:block = 59048; // Max value of a nyte (9^5 - 1) / 2
2. Rational Numbers
(frac)
To completely eliminate rounding errors inherent in
floating-point division, Nitpick natively supports
fractional representations where the numerator and
denominator are stored exactly. * frac8,
frac16, frac32,
frac64
Usage Example:
frac32:ratio = 1/3frac32;
// Math operations with ratios stay perfectly precise.
3. Complex Numbers
(cplx)
Native support for numbers with real and imaginary
components. * cplx32, cplx64
Usage Example:
cplx64:wave = 5.0+2.0icplx64;
4. Hardware Primitives
Nitpick includes explicit native types for advanced
hardware acceleration. * simd : Explicit
Single-Instruction-Multiple-Data vector operations. *
atomic : Lock-free thread-safe primitives.
Usage Example:
atomic<int32>:counter = 0i32;
// Atomic operations will map directly to hardware lock CMPXCHG instructions.