Skip to Content
Cloth
DocumentationReferenceTypesBoolean, Char, and Byte

Boolean, Char, and Byte

Cloth provides four small named types for logical values, character data, and byte-level work: bool, char, byte, and bit.

bool

bool represents a logical value. It has exactly two values, denoted by the literals true and false.

let active = true; let done = false;

bool is the type produced by every comparison operator (==, !=, <, <=, >, >=) and by the type-check (is) and membership-check (in) operators. It is the required type of the condition expression in if, while, do-while, and the C-style for.

The logical operators and and or operate on bool operands and produce a bool result. The unary operator ! negates a bool.

The standard library provides a println overload for bool that prints the literal text true or false:

import cloth.io.Out::{ println }; println(true); // prints: true println(false); // prints: false

char

char represents a single character. It is a fixed-size value type and may be passed, stored, and compared like any other primitive.

char is distinct from string. A string is a sequence of characters; a char is a single character. Conversion between the two is explicit.

byte

byte represents an 8-bit value. It is the type used when working with raw memory, file contents, or other binary data where individual octets are the unit of meaning.

byte corresponds in size to u8. The two are distinct types in source — they differ in intent: u8 represents an unsigned integer in the range 0–255, while byte represents an opaque octet whose interpretation depends on the surrounding context.

bit

bit represents a single bit. It is the smallest addressable value in Cloth and is used in contexts where a single Boolean-like signal is more appropriate than a full bool — for example, when describing bitfields or hardware-level data layouts.

Summary

TypeWidthDomain
bool1 (logical)true, false
charplatform-defined character widtha single character
byte8 bits0..=255, no interpretation
bit1 bit0 or 1

These four types are reserved keywords and cannot be redefined.