Learn

The binary blog

Plain guides to binary, hex, text encoding and file sizes. Each one links to the tool that does the math.

In an 8-bit signed integer, 127 + 1 equals -128.Featured · Binary basics

MSB and LSB: most and least significant bits, signed integers and overflow

The MSB is the leftmost, highest-value bit and the LSB the rightmost. See what each tells you, how signed integers use the MSB as a sign bit, and how integer overflow wraps values around.9 min read

Latest guides

The xxd command turns hello.txt into the hex 4865 6c6c 6f2c.Programming

The xxd command: hex dumps on Linux and macOS

Use xxd to read the bytes in any file, get plain hex with -p, turn hex back into binary with -r, patch a byte, print bits, make C arrays and diff binary files.9 min read
In floating point, 0.1 + 0.2 equals 0.30000000000000004.Binary basics

Floating point numbers explained: why 0.1 + 0.2 is not 0.3

A floating point number is scientific notation in binary. See why 0.1 + 0.2 is 0.30000000000000004, how precise floats are, float vs double, and how to compare floats and handle money.9 min read
The hexadecimal number 2F3 equals 755 in decimal.Binary basics

What is hexadecimal? The base 16 number system explained

Hexadecimal is base 16, with digits 0 to 9 and A to F. See how place values work, why programmers use hex for bytes, the values worth knowing and how octal compares.7 min read
The text Hi! encoded in Base64 is SGkh.Binary basics

What is Base64? How Base64 encoding works

Base64 writes any data with 64 safe characters. See the bit-by-bit steps, the alphabet, why strings end in = or ==, why the result is a third bigger and where you will meet it.10 min read
The text Hello encoded in Base64 is SGVsbG8=.Programming

Base64 encode and decode in Python, JavaScript, Linux and PowerShell

Base64 one-liners for Python, the browser, Node.js, Linux, macOS and PowerShell, with a command builder and fixes for padding errors, echo newlines, line wrapping and UTF-16.13 min read
Python 12 XOR 10 equals 6.Programming

Python bitwise operators and XOR, with examples

Python's bitwise operators &, |, ^, ~, << and >> explained bit by bit. XOR for flipping bits, ciphers and logical XOR, masks and flags, shifts, and & versus and.10 min read
Python struct.pack('<I', 1000) returns the bytes e8 03 00 00.Programming

Python struct: pack and unpack binary data

The struct module packs Python numbers into bytes and unpacks them again. Format characters, byte order, alignment, a PNG header example, records, IPv4 and the common errors.11 min read
Python bin(200) returns 0b11001000.Programming

Convert int to binary and hex in Python, and back

Convert integers to binary, hex and octal strings in Python and back again. Padding, removing the 0b prefix, negative numbers in two's complement, text to binary and a cheat sheet.9 min read
Python bytes b'Hi' decoded to the string 'Hi'.Programming

Python bytes to string and string to bytes

Convert bytes to a string with decode() and a string to bytes with encode(). Includes a live encoder, the str(b) bug, UnicodeDecodeError fixes, int.to_bytes() and hex.11 min read
Python ord('a') returns 97.Programming

Python ord() and chr(): character to number and back

ord() returns the Unicode number of a character and chr() turns a number back into a character. Examples for ASCII, accented letters and emoji, plus the errors and how to fix them.9 min read
Unicode, UTF-8 and ASCII: the euro sign, code point U+20AC, is stored in UTF-8 as the bytes E2 82 AC.Binary basics

Unicode, UTF-8 and ASCII explained

ASCII, Unicode and UTF-8 explained: the 128 ASCII codes, Unicode code points, how UTF-8 stores them in 1 to 4 bytes, UTF-16 compared, and what causes garbled text.8 min read
Half adder and full adder: 1 plus 1 equals 10 in binary, a sum of 0 and a carry of 1.Binary basics

Half adder and full adder

Half adder and full adder circuits with truth tables and Boolean equations, a full adder built from two half adders, a 4-bit ripple carry adder you can try, and subtraction with the same circuit.7 min read
Big endian vs little endian: the number 0x1234 is stored as 12 34 in big endian and as 34 12 in little endian.Binary basics

Big endian vs little endian

What endianness means, how 0x12345678 sits in memory in each order, which processors and file formats use which, network byte order, hex dumps and code to convert.8 min read
Binary subtraction: 1010 minus 0111 equals 0011, which is 10 minus 7 equals 3.Binary basics

Binary subtraction

How to subtract binary numbers: the four rules, borrowing step by step, the two's complement and one's complement methods, common mistakes and practice problems with answers.7 min read
Boolean algebra: 1 OR 1 equals 1.Binary basics

Boolean algebra explained

Boolean algebra from the start: the three operations, every law in one table, three worked simplifications, truth tables, sum of products, and a calculator that builds the table for you.8 min read
De Morgan's law: NOT of A AND B equals NOT A OR NOT B.Binary basics

De Morgan's law explained

Both of De Morgan's laws with a truth table proof, a live checker, step-by-step examples, practice problems, and how the laws work in logic gates and in code.8 min read
Logic gates explained: 1 AND 0 equals 0.Binary basics

Logic gates explained

The 7 basic logic gates with symbols, Boolean expressions and truth tables, a live tester for every gate, and how NAND gates and half adders turn bits into arithmetic.9 min read
Powers of 2: 2 to the power of 10 equals 1024.Binary basics

Powers of 2

The full powers of 2 chart from 2^0 to 2^64, a calculator for any exponent, and why 256, 1,024 and 65,536 keep showing up in bytes, colors and file sizes.6 min read
What is binary code: the binary number 1101 equals 13 in decimal.Binary basics

What is binary code?

Binary code stores numbers, text, colors, sound and programs with only 0 and 1. See how bits and bytes work, why computers chose two digits and what Hello looks like in binary.8 min read
How to read binary: the byte 01001000 turns into the letter H.Binary basics

How to read binary

Split binary into bytes, add the place values under the 1s, then look the number up in the ASCII table. Worked examples, practice bytes and a live bit flipper.7 min read
Scroll to Top