Under heavy development. This site describes the intended 1.0 language. Current features and performance vary. Development status
Sn50SnThe SnAPI programming language
Development · Evolving reference

byte

One object-representation octet; distinct from u8.

Sn is under heavy development. This reference includes the intended 1.0 design; features may be incomplete in the current compiler. Read the status →

These examples describe the Development language contract. They are not a claim that every workflow is supported by the current public preview. Declaration excerpts belong inside a function unless a full module is shown.

Valid values and representation

A byte has 8-bit storage compatible with u8 and valid unsigned values 0 through 255. Its role is object representation, buffers and native character storage. Storage compatibility does not make byte and u8 interchangeable semantic types. A byte is not a Unicode scalar.

let Minimum: byte = 0_byte;
let Maximum: byte = 255_byte;
let Ascii: byte = b'A';
let Raw: byte = b'\xFF';

Operations

byte supports equality, unsigned-value order, bitwise ~ / & / ^ / |, and shifts. It does not provide integer arithmetic or implicit mixing with u8. Shift counts follow the checked-count rule: 0 through 7 for ordinary shifts.

let Flags: byte = 0b1010_0001_byte;
let Masked: byte = Flags & 0x0F_byte; // 1
let Shifted: byte = Flags >> 4; // 10
// Rejected: let Next = Flags + 1_byte;

Conversions and literals

Use _byte, a fitting byte context, or b'...'. A byte character literal accepts one ASCII byte or a byte escape; Unicode escapes are rejected. Use explicit numeric conversion when arithmetic is needed; converting back checks the byte range.

let Raw: byte = 200_byte;
let Number: u8 = Raw as u8;
let Increased: u16 = (Number as u16) + 100_u16;
let Fits: byte? = Increased as? byte; // none

See all primitive types and literals and user-defined suffixes.

Documentation snapshot: October 24, 2026 About versions ↗
Searching Development · language & standard library