Byte
A byte is a group of bits treated as one storage unit, conventionally eight bits in modern storage and networking.
Units: Modern storage capacity uses 1 B = 8 bits. An octet is explicitly an eight-bit group: its 256 patterns range from hexadecimal 00 to FF. Octet is an alias here only for the eight-bit usage of byte. [1] [3]
C portability: The C11 draft defines a byte as an addressable storage unit, with implementation-defined width. CHAR_BIT gives its bit count and must be at least 8; sizeof(char) is 1, not a promise of eight bits. A serialized octet and a C byte therefore need not have the same width. [2]
Text: A byte count is not a character count. UTF-8 encodes one Unicode scalar value in one to four octets, excluding surrogate code points. For example, U+0041 occupies 41 in hexadecimal, while U+20AC occupies E2 82 AC. Count the encoded bytes when sizing a text payload. [4]
Relations
- related
- Bit, Binary prefix, Byte order, File size, Character encoding, UTF-8, Unicode normalization, Hexadecimal byte encoding
Citations
- NIST: Prefixes for binary multiples, unit examples
- WG14 N1570, C11 committee draft: sections 3.5-3.6, 5.2.4.2.1 and 6.5.3.4
- RFC 5234: Appendix B.1, OCTET core rule
- RFC 3629: section 3, UTF-8 definition
Sources & caveats
- The C-specific statement is scoped to the April 2011 N1570 committee draft. UTF-8 examples describe encoding, not filesystem allocation.