How RLE Encode a Binary Number Works
RLE Encode a Binary Number compresses repetitive binary bitstreams into lossless run-length tokens across four industry-standard formats including classic Fax alternating-run notation and JSON.
Binary arithmetic and base-2 encoding form the physical foundation of digital microprocessors, network packets, memory buffers, and cryptographic primitives. Every calculation in this utility runs directly inside your browser using exact JavaScript BigInt and typed-array pipelines, so arbitrary-length bitstreams, 128-bit addresses, and raw byte buffers never suffer from 53-bit IEEE floating-point truncation or server latency.
Lossless Binary Run-Length Compression
Scan left-to-right: replace k consecutive copies of bit b with token (k, b) Fax Optimization: store only initial bit + sequence of alternating run lengths!
Because binary has only two symbols (0 and 1), once the starting bit is known every subsequent run automatically toggles polarity — the exact principle behind ITU-T Group 3/4 fax compression.
Worked Reference Examples
| Input | Output | Step / Bit Note |
|---|---|---|
| 0000000011111 | 8:0 5:1 | 13 bits -> 2 runs (avg 6.5) |
| Fax format | 0, 8, 5 | Initial bit 0, then alternating lengths |
| 10101010 | 1:1 1:0 1:1 ... | Alternating bits do not compress |
Practical Engineering Applications
1-Bit Image & Fax Compression
Encode monochrome bitmap scanlines efficiently before transmission.
Compression Benchmarking
Measure average run length to decide whether RLE or Huffman/LZ77 fits your bitstream.
Precision, Edge Cases & Best Practices
Pairs directly with our RLE Decode a Binary Number tool for instant round-trip verification.
All input parsing strips harmless formatting whitespace, underscores, or common prefixes such as 0b where applicable, while preserving exact bit order and padding width so outputs drop straight into C/C++, Rust, Verilog, VHDL, Python, and embedded firmware test harnesses.