Modules · Data

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

NameTypeDescription
valueMaths.IntegerThe 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);
Placing a whole number into a byte

Binary.Byte.ToInteger

Reads a byte back out as a plain integer 0..255.

Parameters

NameTypeDescription
valueBinary.ByteThe byte to read back out.

Returns

A Maths.Integer in the range 0..255.

Example

const n = Binary.Byte.ToInteger(b);
Reading a byte back out as an integer

Binary.Word.FromBytes

Builds a word from a high and a low byte: high * 256 + low.

Parameters

NameTypeDescription
highBinary.ByteThe high byte, worth 256 each.
lowBinary.ByteThe 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);
Building a word from two bytes

Binary.Word.FromInteger

Places a whole number into a word; wraps mod 65536 so the result is always a valid 0..65535 word.

Parameters

NameTypeDescription
valueMaths.IntegerThe 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);
Placing a whole number into a word

Binary.Word.HighByte

The top 8 bits of a word: Floor(word / 256).

Parameters

NameTypeDescription
valueBinary.WordThe 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);
Taking the high byte of a word

Binary.Word.LowByte

The bottom 8 bits of a word: word mod 256.

Parameters

NameTypeDescription
valueBinary.WordThe 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);
Taking the low byte of a word

Binary.Word.ToInteger

Reads a word back out as a plain integer 0..65535.

Parameters

NameTypeDescription
valueBinary.WordThe word to read back out.

Returns

A Maths.Integer in the range 0..65535.

Example

const n = Binary.Word.ToInteger(word);
Reading a word back out as an integer