Binary to Negabinary Converter
Convert between binary (base 2) and negabinary (base โ2) number systems instantly. View step-by-step breakdowns with decimal intermediates.
About
Negabinary (base โ2) is a non-standard positional numeral system that represents every integer - positive, negative, and zero - without a sign symbol. This property makes it relevant in certain digital circuit designs and theoretical computer science. A miscalculation in radix conversion propagates through every downstream operation: arithmetic, checksums, protocol encoding. This tool converts between standard binary (base 2) and negabinary (base โ2) using exact BigInt arithmetic, eliminating overflow errors that occur with naive 32-bit implementations. An intermediate decimal value is shown so you can verify each conversion step independently.
The conversion algorithm follows the Schroeppel method for negative-base encoding: repeated division by โ2 with remainder correction. Note: both binary and negabinary use only digits 0 and 1, so the string representation alone cannot tell you which system it belongs to - context is everything. The tool assumes unsigned binary input (no two's complement). Pro tip: negabinary addition requires a specialized carry rule where a carry of 1 into position k produces โ1 at position k+1, not +1.
Formulas
In standard binary (base 2), a digit string dndnโ1โฆd0 represents the value:
In negabinary (base โ2), the same digit string uses a negative base:
To convert a decimal integer N to negabinary, apply the Schroeppel division algorithm:
The remainder r is always forced to 0 or 1. When the standard modulo yields a negative remainder, add 2 to r and increment the quotient by 1. Digits are collected from least significant to most significant. The process terminates when N = 0.
Where: N = decimal integer value, di = digit at position i (either 0 or 1), r = remainder after division, i = bit position index (starting from 0).
Reference Data
| Decimal | Binary (base 2) | Negabinary (base โ2) | Positional Weights (base โ2) |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 1 | 1 | 1 | 1 |
| 2 | 10 | 110 | 4 + (โ2) + 0 |
| 3 | 11 | 111 | 4 + (โ2) + 1 |
| 4 | 100 | 100 | 4 |
| 5 | 101 | 101 | 4 + 0 + 1 |
| 6 | 110 | 11010 | 16 + (โ8) + 0 + (โ2) + 0 |
| 7 | 111 | 11011 | 16 + (โ8) + 0 + (โ2) + 1 |
| 8 | 1000 | 11000 | 16 + (โ8) |
| 9 | 1001 | 11001 | 16 + (โ8) + 1 |
| 10 | 1010 | 11110 | 16 + (โ8) + 4 + (โ2) |
| โ1 | N/A (unsigned) | 11 | (โ2) + 1 |
| โ2 | N/A (unsigned) | 10 | โ2 |
| โ3 | N/A (unsigned) | 1101 | (โ8) + 4 + 0 + 1 |
| โ4 | N/A (unsigned) | 1100 | (โ8) + 4 |
| โ5 | N/A (unsigned) | 1111 | (โ8) + 4 + (โ2) + 1 |
| โ6 | N/A (unsigned) | 1110 | (โ8) + 4 + (โ2) |
| โ10 | N/A (unsigned) | 10110 | 16 + 0 + 4 + (โ2) + 0 |
| 15 | 1111 | 10001 | 16 + 0 + 0 + 0 + 1 |
| 16 | 10000 | 10000 | 16 |
| 20 | 10100 | 10100 | 16 + 0 + 4 |
| 32 | 100000 | 1100000 | 64 + (โ32) |
| 42 | 101010 | 1110110 | 64 + (โ32) + 16 + 0 + 4 + (โ2) + 0 |
| 100 | 1100100 | 110100100 | 256 + (โ128) + 0 + 32 + 0 + 0 + 4 + 0 + 0 |
| 255 | 11111111 | 100000011 | 256 + 0 + โฆ + (โ2) + 1 |