Binary
The low-level whole-number types that sit under the Clip.Data
texture-packing codecs, plus the handful of operations for moving numbers in and out of them.
Binary.Byte is a native 8-bit whole number 0..255, and Binary.Word is a
native 16-bit whole number 0..65535 (a pair of bytes). A byte is exactly what a GPU texture channel
holds, so anything that packs a value into a texture ends up as Binary.Byte values.
Both types are native primitives and their names double as namespaces, so a function like
Binary.Byte.FromInteger hangs directly off the type. Nothing computes inline: every
operation is a typed record emitted on the binary channel and filled by the always-active
binary driver once its operands settle, so the whole surface stays driver-based and
statically checkable.
Contents
Functions
Functions
Binary.Byte.FromInteger
Places a whole number into a byte; wraps mod 256 so the result is always a valid 0..255 byte.
Parameters
| Name | Type | Description |
|---|---|---|
value | Maths.Integer | The whole number to place into the byte. |
Returns
A Binary.Byte: the value wrapped mod 256, so always 0..255. A value already in range is unchanged.
Example
const b = Binary.Byte.FromInteger(200);Binary.Byte.ToInteger
Reads a byte back out as a plain integer 0..255.
Parameters
| Name | Type | Description |
|---|---|---|
value | Binary.Byte | The byte to read back out. |
Returns
A Maths.Integer in the range 0..255.
Example
const n = Binary.Byte.ToInteger(b);Binary.Word.FromBytes
Builds a word from a high and a low byte: high * 256 + low.
Parameters
| Name | Type | Description |
|---|---|---|
high | Binary.Byte | The high byte, worth 256 each. |
low | Binary.Byte | The low byte, worth 1 each. |
Returns
A Binary.Word equal to high * 256 + low, in the range 0..65535.
Example
const high = Binary.Byte.FromInteger(1);
const low = Binary.Byte.FromInteger(44);
const word = Binary.Word.FromBytes(high, low);Binary.Word.FromInteger
Places a whole number into a word; wraps mod 65536 so the result is always a valid 0..65535 word.
Parameters
| Name | Type | Description |
|---|---|---|
value | Maths.Integer | The whole number to place into the word. |
Returns
A Binary.Word: the value wrapped mod 65536, so always 0..65535.
Example
const w = Binary.Word.FromInteger(30000);Binary.Word.HighByte
The top 8 bits of a word: Floor(word / 256).
Parameters
| Name | Type | Description |
|---|---|---|
value | Binary.Word | The word to take the high byte of. |
Returns
A Binary.Byte equal to Floor(word / 256): the top 8 bits.
Example
const high = Binary.Word.HighByte(word);Binary.Word.LowByte
The bottom 8 bits of a word: word mod 256.
Parameters
| Name | Type | Description |
|---|---|---|
value | Binary.Word | The word to take the low byte of. |
Returns
A Binary.Byte equal to word mod 256: the bottom 8 bits.
Example
const low = Binary.Word.LowByte(word);Binary.Word.ToInteger
Reads a word back out as a plain integer 0..65535.
Parameters
| Name | Type | Description |
|---|---|---|
value | Binary.Word | The word to read back out. |
Returns
A Maths.Integer in the range 0..65535.
Example
const n = Binary.Word.ToInteger(word);