← All examples

To bits

The base keeps a way to write numbers like the hardware, never the default: to.T.bits[…] reads a value's bits as T's.

to_bits.zg
# The base keeps a way to write numbers like the hardware, never the default (owner, 2026-10-06):
# `to.T.bits[…]` reads a value's bits as T's.

MAIN {
    let 'a' := to.int8.bits[128];        # 128's bits in an int8: -128
    let 'b' := to.uint8.bits[-1];        # -1's bits in a uint8: 255
    let 'c': uint8 = 200;
    let 'd' := to.int8.bits['c'];        # 200's bits: -56
    std::print.useful['a', " ", 'b', " ", 'd', newln];
}
Output
-128 255 -56