πŸ”’ Bit Playground β€” All Bases Live
Bit width:
Mode:
Binary (Base 2)
Octal (Base 8)
Decimal (Base 10)
Hexadecimal (Base 16)
πŸ“ Step-by-step: Decimal β†’ Binary
Quick examples
Why different bases?

Computers work in binary (base 2) because circuits are either on or off. Octal and Hex are shorthand β€” each hex digit = 4 bits, so programmers use hex to read binary more easily.

Two's Complement (Signed)

To store negative numbers, computers use two's complement: flip all bits, then add 1. The most significant bit (MSB) acts as the sign bit: 0=positive, 1=negative.

–1 in 8-bit = 11111111
–128 in 8-bit = 10000000
127 max positive = 01111111
Range reference (8-bit)
Type Min Max
Unsigned 0 255
Signed -128 127
Overflow demo

In 8-bit unsigned: 255 + 1 = 0 (wraps around). In 8-bit signed: 127 + 1 = -128!

πŸ“¦ Data Types & Memory Layout
Click a type to explore its size, range, and bit layout
RAM Memory Layout β€” variables side by side:
Why different types?

Using a bool for true/false wastes space if you used int. Using float lets you store decimals. Choosing the right type saves memory and speeds up programs.

IEEE 754 Float (32-bit)

Floats split 32 bits into 3 fields:

1 bit: Sign 8 bits: Exponent 23 bits: Mantissa

Value = (–1)sign Γ— 2exp–127 Γ— 1.mantissa

Struct layout example
struct Example {
char c; // 1 byte β†’ addr 0x00
int i; // 4 bytes β†’ addr 0x04 (aligned)
double d; // 8 bytes β†’ addr 0x08
} // total: 16 bytes with padding
βš™οΈ Bitwise Operations Lab
Operate on individual bits β€” the foundation of computer logic
What are bitwise ops?

Bitwise operators work bit by bit on two numbers, comparing each bit position using logic gate rules.

AND
Real-world uses
πŸ”’AND: check/clear specific bits (bitmasks)
πŸ”“OR: set specific bits to 1
πŸ”XOR: toggle bits, simple encryption
β¬…Left shift: fast multiply by 2
➑Right shift: fast divide by 2
πŸ“ Text Encoding β€” ASCII, UTF-8 & Unicode
Encoding:
How this string lives in memory:
+ null terminator 0x00 at the end (C-style strings)
πŸ“œ
ASCII uses 7 bits (128 chars). UTF-8 is backward-compatible but uses 1–4 bytes per character β€” emojis like 🌍 need 4 bytes!
ASCII vs UTF-8
Char ASCII UTF-8 bytes
A 0x41 1 byte: 41
Γ© N/A 2 bytes: C3 A9
δΈ­ N/A 3 bytes: E4 B8 AD
🌍 N/A 4 bytes: F0 9F 8C 8D
Unicode code points

Every character in every language has a code point (e.g. U+0041 for 'A'). UTF-8 is one way to encode these as bytes.

🎨 Colours & Image Storage
#FF6B6B
3 bytes per pixel Β· 24-bit colour
25511111111
10701101011
10701101011
Hex = R(2 digits) + G(2 digits) + B(2 digits):
FF + 6B + 6B = #FF6B6B
πŸ–ΌοΈ Paint pixels β€” see how each one is stored:
Selected pixel:
Position: β€”
R binary: β€”
G binary: β€”
B binary: β€”
Storage: 3 bytes = 24 bits
Paint colour:
Image file size
Size Uncompressed
100Γ—100 30,000 bytes (30 KB)
1920Γ—1080 ~6.2 MB
4K (3840Γ—2160) ~24 MB
Preset colours