Base βˆ’2 Converter & Calculator (digits 0 and 1)

Number System Converter

Decimal β†’ Negabinary
Negabinary β†’ Decimal
Binary β†’ Negabinary
Negabinary β†’ Binary

Converts automatically as you type.

Negabinary value
β€”

About Negabinary (Base βˆ’2)

Negabinary is a positional numeral system with base βˆ’2 and digits 0 and 1. It represents every integer β€” positive, negative, and zero β€” without a minus sign, because its places alternate between positive and negative powers of two: … βˆ’8, +4, βˆ’2, +1.

Quick sign check: a numeral with an odd number of digits is positive (its leading 1 sits on a positive power), and one with an even number of digits is negative. 110 = +2, but 11 = βˆ’1.

This tool computes with exact integer arithmetic (BigInt), so even very long numerals convert without rounding errors. Inputs accept up to 64 negabinary digits or 18-digit decimals.

Negabinary Calculator

 
= 0

Keyboard: 0 1 digits Β· + βˆ’ Γ— / operators Β· Enter equals Β· Backspace delete Β· Esc clear Β· N negate

How It Works

Enter numbers as negabinary bit strings. The live line under the display shows the exact decimal value at every step, and the small line above it shows the pending operation. Internally the calculator converts to decimal, computes with exact integer arithmetic, and converts back.

Division gives the integer quotient (truncated toward zero); the decimal line reports any remainder. A neat base βˆ’2 trick: appending a 0 multiplies a number by βˆ’2.

Negabinary Utilities

Number Range Calculator

Find the exact range of integers representable with a given number of negabinary bits.

Bitwise Operations

Apply AND, OR, or XOR to two negabinary bit patterns (aligned at the units place). Note: these act on the digit patterns β€” the decimal results don't follow ordinary two's-complement bitwise rules.

Parity Checker

Determine instantly whether a negabinary number is even or odd β€” only the last digit matters, because every other place value is even.

Negabinary Reference

Place Values: powers of βˆ’2

Position(βˆ’2)ⁿValue

Quick Rules

Sign at a glance: odd digit count β†’ positive, even digit count β†’ negative (only 0 is neither).

Parity: the last digit is the parity β€” …1 is odd, …0 is even.

Multiply by βˆ’2: append a 0.

Negation is not bit-flipping: βˆ’(1) is 11, not 0. Changing sign requires real arithmetic.

Uniqueness: every integer has exactly one negabinary representation (without leading zeros).

Value Chart: βˆ’16 to +16

Note how positives and negatives interleave without any sign symbol. The teal rows are positive, orange negative.

DecimalNegabinaryDigitsDecimalNegabinaryDigits

Learn: Why Base βˆ’2?

A signless number system

Negative bases were first described by Vittorio GrΓΌnwald in 1885, and base βˆ’2 later moved from curiosity to hardware: Polish computers of the late 1950s and early 1960s β€” the UMC series designed around ZdzisΕ‚aw Pawlak's "minus-two" arithmetic β€” actually computed in negabinary.

The appeal: with base βˆ’2 there is no sign bit, no two's complement, and no separate rules for negative numbers. Every integer is just a string of 0s and 1s, and the same addition circuitry handles positives and negatives alike. The trade-off is that comparisons and sign tests become less direct β€” which is why base 2 plus two's complement won out in mainstream hardware.

How the range grows: a lopsided ladder

Each extra bit doubles how many integers fit (so each bar below is drawn one step longer, on a doubling scale), but the new territory alternates sides: an even-positioned bit extends the positive reach, an odd-positioned bit the negative. The split keeps flip-flopping between roughly β…“ / β…”.

negative side of the range positive side (plus zero)
← minbar length ∝ bits (range doubles per bit)max β†’

Example: 8 bits cover βˆ’170 … +85, while 9 bits cover βˆ’170 … +341 β€” the ninth bit adds only positive numbers.

Converting by hand

1. Divide the number by βˆ’2 and truncate toward zero. If the remainder is negative, add 2 to it and add 1 to the quotient β€” remainders must be 0 or 1.

2. Write down the remainder; the quotient becomes the new number.

3. Repeat until the quotient is 0. The remainders, read last-to-first, are the negabinary digits.

Example for βˆ’9: the steps produce remainders 1, 1, 0, 1 β€” read last-to-first: 1011. Check: 1Γ—(βˆ’8) + 0Γ—(+4) + 1Γ—(βˆ’2) + 1Γ—(+1) = βˆ’9. Try it in the Converter tab β€” the diverging chart walks through every place for you.

Quick Quiz: Test Your Knowledge!

Pick the decimal value of each negabinary number. Build a streak!

0
Score
0
Streak
0
Best streak

…