0

Can anyone help me understand what is base -2? I understand base in positive integers and know how to convert a decimal number to those bases, but really do not have any idea with negative base.

David Bejar
  • 512
  • 4
  • 20
Will Best
  • 211
  • 1
  • 3
  • 6

1 Answers1

0

This exotic base descried in the book: http://www.hackersdelight.org/hacker2TOC.pdf And, is not practical.

But, basic idea as same as with a regular binary code:

ABCD == A*(-2)^3 + B*(-2)^2 + C*(-2) + D

Example of numbers:

-2          Decimal
-------------------
000              0
001              1
010             -2
011             -1
100              4
101              5

And so on.

olegarch
  • 3,670
  • 1
  • 20
  • 19