Numbers
The Numbers category covers functions for converting integers to and from positional notation in another base. You can call each one in prefix form fn(n, …) or postfix/UFCS form n fn(…).
General arithmetic —
abs,ceil,floor,round,sqrt,pow,mod,sum,avg,min,max, and the rest of the math toolkit — lives in the Core category, not here.
TransformScript number literals are always plain base-10 integers and decimals; there is no 0x, 0b, or exponent literal syntax. These functions are how you read and write values in another base. Conversions operate on integers (a non-integer input raises an error), and the radix must be between 2 and 36. Output strings use lowercase digits 0-9a-z, and negative numbers keep a leading -.
| Function | Signature | Description | Example |
|---|---|---|---|
toBinary | (:number?) | Returns the base-2 (binary) string for an integer. Returns null if the argument is null. | toBinary(10) → "1010" |
fromBinary | (:string?) | Parses a base-2 (binary) string back into a number. Returns null if the argument is null. | fromBinary("11111111") → 255 |
toRadixNumber | (:number, :number) | Returns the string for an integer in the given radix (2–36). | toRadixNumber(255, 16) → "ff" |
fromRadixNumber | (:string, :number) | Parses a string of the given radix (2–36) back into a number. | fromRadixNumber("z", 36) → 35 |
Related
- Core —
abs,ceil,floor,round,sqrt,pow,mod,sum,avg,min,max, and the rest of the math toolkit. - Coercions —
toNumber,toString, and the other type converters. - Binaries — base64 / hex encoding and byte-level operations.
- Function Library — all categories.