Alternating Binary Sequence Generator
Generate alternating binary sequences (0101... or 1010...) with custom length, format, grouping, and separators. Copy or download instantly.
About
An alternating binary sequence is a deterministic pattern where each bit is the logical complement of its predecessor: bi = (s + i) mod 2, where s β {0, 1} is the starting bit. These sequences appear in clock signal testing, UART idle-line detection, Manchester encoding validation, and PRBS baseline comparisons. Getting the phase or length wrong in hardware test vectors can mask timing violations or cause false pass results on boundary-scan tests.
This generator produces sequences up to 100,000 bits with configurable grouping (nibbles, bytes, words) and output formats. It approximates no randomness. The output is fully deterministic. Note: for sequences exceeding your clipboard limit, use the file download option.
Formulas
The alternating binary sequence is defined by a simple recurrence. Given a starting bit s and sequence length n, each bit at position i is computed as:
Where s = 0 produces the sequence 010101β¦ and s = 1 produces 101010β¦.
The Hamming weight (count of 1-bits) for a sequence of length n starting with s is:
Where bi is the bit value at index i, s is the starting bit (0 or 1), n is the total sequence length, and H is the Hamming weight of the output.
Reference Data
| Property | Value / Description |
|---|---|
| Sequence Type | Deterministic alternating binary |
| Starting Bit Options | 0 (0101...) or 1 (1010...) |
| Min Length | 1 bit |
| Max Length | 100,000 bits |
| Period | 2 (repeats every 2 bits) |
| Duty Cycle | 50% (equal 0s and 1s for even lengths) |
| Hamming Weight (even n) | n2 |
| Autocorrelation at lag 1 | β1 (perfect anti-correlation) |
| Run Length | 1 (every run is exactly one bit) |
| Nibble Grouping | 4 bits per group |
| Byte Grouping | 8 bits per group |
| Word Grouping | 16 bits per group |
| Common Application: Clock Signal | Square wave at f2 of bit rate |
| Manchester Encoding Baseline | Alternating bits produce constant transitions |
| UART Idle Pattern | Continuous 1s (not alternating) - use for contrast testing |
| Hex of 01010101 | 0x55 |
| Hex of 10101010 | 0xAA |
| Decimal of 01010101 | 85 |
| Decimal of 10101010 | 170 |
| Bit Error Rate Test (BERT) | Alternating pattern used as reference baseline |
| I2C SDA Stress Pattern | Alternating bits maximize transition density |
| CRC of 0x55 (CRC-8) | 0x93 |