The unsigned byte: pixel colors, raw binary data, and ML image preprocessing
An 8-bit unsigned integer uses all 8 bits for magnitude, giving a range of 0 to 255 (28 - 1). It is the unsigned char type in C/C++, byte in C#/Java, and u8 in Rust.
UINT8 is the fundamental unit of byte-addressable memory. Its 256 possible values are sufficient for color channels, character encodings, and raw binary protocols. In machine learning, UINT8 is the standard input format for image data before normalization to float.
| Property | Value |
|---|---|
| Total Bits | 8 |
| Minimum Value | 0 |
| Maximum Value | 255 |
| Representable Values | 256 |
| Value | Bit Pattern | Signed | Unsigned |
|---|---|---|---|
| Zero | 00000000 | 0 | 0 |
| One | 00000001 | 1 | 1 |
| Max Unsigned | 11111111 | -1 | 255 |
| Max Signed | 01111111 | 127 | 127 |
| All Ones (-1) | 11111111 | -1 | 255 |
| Min Signed (-128) | 10000000 | -128 | 128 |
Click any of the 8 bits to flip them. With only 256 possible values, you can explore the entire format.
| Property | UINT8 | UINT32 | UINT16 | UINT4 |
|---|---|---|---|---|
| Total Bits | 8 | 32 | 16 | 4 |
| Signed Min | -128 | -2,147,483,648 | -32,768 | -8 |
| Signed Max | 127 | 2,147,483,647 | 32,767 | 7 |
| Unsigned Max | 255 | 4,294,967,295 | 65,535 | 15 |
| Step (ULP) | 1 | 1 | 1 | 1 |
| Values | 256 | 4,294,967,296 | 65,536 | 16 |
torch.uint8 for image tensor storage. The ONNX specification defines UINT8 = 2 as a core data type..u8x4 packed types for unsigned byte operations. cuDNN supports UINT8 in INT8x4 packed tensor formats for inference.