Binary Data and Encoding
Binary data and encoding covers how computers represent, store, and transmit information below the text layer: number systems, byte ordering, character encodings, serialization formats, and the conversions needed when moving data between systems that make different assumptions about representation.
itComputer fundamentals | OpenSkills.info
Intro
Binary Data and Encoding
Computers store and move bits. A bit has one of two values: zero or one. Eight bits form a byte, which can represent 256 distinct bit patterns. Those patterns have no built-in meaning.
Consider the byte 01000001. You can interpret it as the unsigned integer 65. In UTF-8, it encodes the letter A. In an image, the same pattern might be one color channel. The bits do not tell you which interpretation is correct. A data format does.
This is the central idea of binary data: representation and meaning are separate. To read bytes correctly, you need metadata or a shared agreement about type, width, byte order, and encoding.
Build values from bits
Binary is a positional numeral system with base two. Each position has a power-of-two weight.
bits: 1 0 1 1 0 1 1 0
weights:128 64 32 16 8 4 2 1
value: 128 + 32 + 16 + 4 + 2 = 182
An unsigned byte covers values from 0 through 255. More bytes provide more patterns. A 16-bit field has 65,536 patterns, while a 32-bit field has more than four billion.
Hexadecimal is a compact way to write bits. Each hexadecimal digit represents four bits, so two digits represent one byte. The byte above is B6 in hexadecimal. Hex dumps, protocol documents, file signatures, memory addresses, and debugging tools use hexadecimal because byte boundaries stay visible.
Continue the course
This section is part of the paid course.
See pricing to subscribe, or log in if you already have access.
Sources
- https://csrc.nist.gov/glossary/term/byte
Supports
- A byte as a sequence of eight bits
- A byte as one of 256 integer values from zero through 255
- https://www.unicode.org/versions/Unicode17.0.0/core-spec/chapter-2/
Supports
- Separation of characters, code points, encoding forms, and encoding schemes
- UTF-8, UTF-16, and UTF-32 encoding forms
- UTF-8 code units as bytes and lack of an endian-order issue within those units
- Byte serialization and byte-order requirements for wider code units
- User-perceived characters potentially containing multiple code points
- https://www.unicode.org/versions/Unicode17.0.0/core-spec/chapter-3/
Supports
- Formal definitions of code point, code unit, Unicode scalar value, and encoding scheme
- Well-formed and ill-formed code-unit sequences
- Canonical equivalence and normalization behavior
- Quiz answer about distinct byte sequences and equivalent text
- https://www.rfc-editor.org/info/rfc3629/
Supports
- UTF-8 as a one-to-four-octet representation of Unicode scalar values
- Preservation of ASCII values as single octets
- Valid UTF-8 byte-sequence syntax
- Security consequences of accepting invalid sequences
- Quiz answers about UTF-8 structure and validation
- https://www.rfc-editor.org/info/rfc4648/
Supports
- Base16, Base32, standard Base64, and URL-safe Base64 alphabets
- Four, five, and six input bits represented per output symbol
- Base64 grouping of three input octets into four output characters
- Padding, canonical encoding, non-alphabet handling, and covert-channel concerns
- Published Base16, Base32, and Base64 test vectors
- Quiz answers about hexadecimal, Base64 purpose, and strict decoding
- https://www.rfc-editor.org/rfc/rfc3550.html#section-4
Supports
- Network byte order as most significant byte first
- Big-endian interpretation of multi-byte integer fields
- A primary protocol example of explicit byte-order and alignment rules
- Quiz answer defining big-endian order
- https://www.rfc-editor.org/rfc/rfc2910.html
Supports
- Signed integer fields encoded with two's-complement binary
- Explicit integer widths of one, two, or four octets
- Big-endian order for those multi-octet integers
- Quiz answer about width and signedness
- https://standards.ieee.org/ieee/754/6210/
Supports
- Binary and decimal floating-point interchange and arithmetic formats
- Arithmetic operations, conversions, exceptions, infinities, and nonnumber values
- Finite floating-point formats and representability constraints
- Quiz answers about rounding and selecting an exact scaled representation
