Negabinary

'Negabinary' (radix -2) is a fairly obscure numeral system used in the experimental Polish computers SKRZAT 1 and BINEG in 1950. It has the unusual property that negative and positive numbers can be represented without a sign bit, although arithmetic operations are more complicated.

Contents

History

Negative numerical bases were discovered by Vittorio Grunwald in his work Giornale di Matematiche di Battaglini, published in 1885. Grunwald gave algorithms for performing addition, subtraction, multiplication, division, root extraction, divisibility tests, and radix conversion. Negative bases were later independently rediscovered by A. J. Kempner in 1936 and Z. Pawlak and A. Wakulicz in 1959.

Writing numbers in negabinary

Every integer can be written uniquely in the form

<math>\sum_{k=0}^{n}d_{k}(-2)^{k}<math>

where each digit dk is either 0 or 1 and the "leading bit" dn is 1 (unless n=0). The negabinary expansion of the given integer is then given by the string dn;dn-1...d1d0. Some negabinary numbers have the same representation in binary. For example,

<math>17=4^2+4^0<math>

and is represented by 10001 in binary and 10001 in negabinary.

The numbers from -5 to 5 with their negabinary expansions are:

-5  1111
-4  1100
-3  1101
-2    10
-1    11
 0     0
 1     1
 2   110
 3   111
 4   100
 5   101
 6 11010

The negabinary expansion of a number can be found by repeated division by -2, recording the non-negative remainders of 0 or 1, and concatenating those remainders, starting with the last. Note that if a / b = c, remainder d, then bc + d = a. For example:

13 / -2 = -6, remainder 1
-6 / -2 =  3, remainder 0
 3 / -2 = -1, remainder 1
-1 / -2 =  1, remainder 1
 1 / -2 =  0, remainder 1

Therefore, the negabinary expansion of 13 is 11101.

Note that the negabinary expansions of negative integers have an even number of bits, while the negabinary expansions of the non-negative integers have an odd number of bits.

Addition

To add two negabinary numbers, start with a carry of 0, and, starting from the least significant bits, add the bits of the two numbers plus the carry. The resulting number is then looked up in the following table to get the bit to write down as result, and the next carry:

number bit carry
  -2    0    1    (Note: -2 only occurs during subtraction.)
  -1    1    1
   0    0    0
   1    1    0
   2    0   -1
   3    1   -1    (Note: 3 only occurs during addition.)

The second row of this table, for instance, expresses the fact that -1 = 1 + 1×(-2); the fifth row says 2 = 0 + -1×(-2); etc.

As an example, to add 1010101 (1+4+16+64 = 85) and 1110100 (4+16-32+64 = 52),

carry:          1 -1  0 -1  1 -1  0  0  0
first number:         1  0  1  0  1  0  1
second number:        1  1  1  0  1  0  0 +
               --------------------------
number:         1 -1  2  0  3 -1  2  0  1
bit (result):   1  1  0  0  1  1  0  0  1
carry:          0  1 -1  0 -1  1 -1  0  0

so the result is 110011001 (1-8+16-128+256 = 137).

Subtraction

To subtract, multiply each bit of the second number by -1, and add the numbers, using the same table as above.

As an example, to compute 1101001 (1-8-32+64 = 25) minus 1110100 (4+16-32+64 = 52),

carry:          0  1 -1  1  0  0  0
first number:   1  1  0  1  0  0  1
second number: -1 -1 -1  0 -1  0  0 +
               --------------------
number:         0  1 -2  2 -1  0  1
bit (result):   0  1  0  0  1  0  1
carry:          0  0  1 -1  1  0  0

so the result is 100101 (1+4-32 = -27).

To negate a number, compute 0 minus the number.

Multiplication and division

Shifting to the left multiplies by -2, shifting to the right divides by -2.

To multiply, multiply like normal decimal or binary numbers, but using the negabinary rules for adding the carry, when adding the numbers.

first number:                   1  1  1  0  1  1  0
second number:                  1  0  1  1  0  1  1 *
              -------------------------------------
                                1  1  1  0  1  1  0
                             1  1  1  0  1  1  0

                       1  1  1  0  1  1  0
                    1  1  1  0  1  1  0

              1  1  1  0  1  1  0                   +
              -------------------------------------
carry:        0 -1  0 -1 -1 -1 -1 -1  0 -1  0  0
number:       1  0  2  1  2  2  2  3  2  0  2  1  0
bit (result): 1  0  0  1  0  0  0  1  0  0  0  1  0
carry:           0 -1  0 -1 -1 -1 -1 -1  0 -1  0  0

For each column, add carry to number, and divide the sum by -2, to get the new carry, and the resulting bit as the remainder.


See also binary, balanced ternary, numeral system.

External resources

  • Vittorio Grunwald. Giornale di Matematiche di Battaglini (1885), 203-221, 367
  • A. J. Kempner. (1936), 610-617
  • Z. Pawlek and A. Wakulicz Bulletin de l'Academie Polonaise des Scienses, Classe III, 5 (1957), 233-236; Serie des sciences techniques 7 (1959), 713-721
  • L. Wadel IRE Transactions EC-6 1957, 123
  • N. M. Blachman, Communications of the ACM (1961), 257
  • IEEE Transactions 1963, 274-276
  • Computer Design May 1967, 52-63
  • R. W. Marczynski, Annotated History of Computing, 1980, 37-48
  • D. Knuth. The Art of Computer Programming, Volume 2, 3rd. Ed. pp204-205nl:Negatief grondtal
Navigation

  • Art and Cultures
    • Art (https://academickids.com/encyclopedia/index.php/Art)
    • Architecture (https://academickids.com/encyclopedia/index.php/Architecture)
    • Cultures (https://www.academickids.com/encyclopedia/index.php/Cultures)
    • Music (https://www.academickids.com/encyclopedia/index.php/Music)
    • Musical Instruments (http://academickids.com/encyclopedia/index.php/List_of_musical_instruments)
  • Biographies (http://www.academickids.com/encyclopedia/index.php/Biographies)
  • Clipart (http://www.academickids.com/encyclopedia/index.php/Clipart)
  • Geography (http://www.academickids.com/encyclopedia/index.php/Geography)
    • Countries of the World (http://www.academickids.com/encyclopedia/index.php/Countries)
    • Maps (http://www.academickids.com/encyclopedia/index.php/Maps)
    • Flags (http://www.academickids.com/encyclopedia/index.php/Flags)
    • Continents (http://www.academickids.com/encyclopedia/index.php/Continents)
  • History (http://www.academickids.com/encyclopedia/index.php/History)
    • Ancient Civilizations (http://www.academickids.com/encyclopedia/index.php/Ancient_Civilizations)
    • Industrial Revolution (http://www.academickids.com/encyclopedia/index.php/Industrial_Revolution)
    • Middle Ages (http://www.academickids.com/encyclopedia/index.php/Middle_Ages)
    • Prehistory (http://www.academickids.com/encyclopedia/index.php/Prehistory)
    • Renaissance (http://www.academickids.com/encyclopedia/index.php/Renaissance)
    • Timelines (http://www.academickids.com/encyclopedia/index.php/Timelines)
    • United States (http://www.academickids.com/encyclopedia/index.php/United_States)
    • Wars (http://www.academickids.com/encyclopedia/index.php/Wars)
    • World History (http://www.academickids.com/encyclopedia/index.php/History_of_the_world)
  • Human Body (http://www.academickids.com/encyclopedia/index.php/Human_Body)
  • Mathematics (http://www.academickids.com/encyclopedia/index.php/Mathematics)
  • Reference (http://www.academickids.com/encyclopedia/index.php/Reference)
  • Science (http://www.academickids.com/encyclopedia/index.php/Science)
    • Animals (http://www.academickids.com/encyclopedia/index.php/Animals)
    • Aviation (http://www.academickids.com/encyclopedia/index.php/Aviation)
    • Dinosaurs (http://www.academickids.com/encyclopedia/index.php/Dinosaurs)
    • Earth (http://www.academickids.com/encyclopedia/index.php/Earth)
    • Inventions (http://www.academickids.com/encyclopedia/index.php/Inventions)
    • Physical Science (http://www.academickids.com/encyclopedia/index.php/Physical_Science)
    • Plants (http://www.academickids.com/encyclopedia/index.php/Plants)
    • Scientists (http://www.academickids.com/encyclopedia/index.php/Scientists)
  • Social Studies (http://www.academickids.com/encyclopedia/index.php/Social_Studies)
    • Anthropology (http://www.academickids.com/encyclopedia/index.php/Anthropology)
    • Economics (http://www.academickids.com/encyclopedia/index.php/Economics)
    • Government (http://www.academickids.com/encyclopedia/index.php/Government)
    • Religion (http://www.academickids.com/encyclopedia/index.php/Religion)
    • Holidays (http://www.academickids.com/encyclopedia/index.php/Holidays)
  • Space and Astronomy
    • Solar System (http://www.academickids.com/encyclopedia/index.php/Solar_System)
    • Planets (http://www.academickids.com/encyclopedia/index.php/Planets)
  • Sports (http://www.academickids.com/encyclopedia/index.php/Sports)
  • Timelines (http://www.academickids.com/encyclopedia/index.php/Timelines)
  • Weather (http://www.academickids.com/encyclopedia/index.php/Weather)
  • US States (http://www.academickids.com/encyclopedia/index.php/US_States)

Information

  • Home Page (http://academickids.com/encyclopedia/index.php)
  • Contact Us (http://www.academickids.com/encyclopedia/index.php/Contactus)

  • Clip Art (http://classroomclipart.com)
Toolbox
Personal tools