Tool to convert numbers with negabinary. The Negabinary system allows to represent positive and negative numbers without bit sign in a binary format (0 and 1) using the base -2.

Négabinary - dCode

Tag(s) : Informatics, Arithmetics

dCode is free and its tools are a valuable help in games, maths, geocaching, puzzles and problems to solve every day!

A suggestion ? a feedback ? a bug ? an idea ? *Write to dCode*!

**Negabinary** writing corresponds to a base $ -2 $ numeral system.

The numbers in the **negabinary** system are described by the formula:

$$ \sum_{i=0}^{n}b_{i}(-2)^{i} $$

With $ b $ a bit and $ i $ its rank in the inverted **negabinary** development (ordered from the end to the beginning).

To convert an integer, it is enough to make a division repeated by $ -2 $ and to concatenate the obtained remainders starting with the end.

__Example:__ `12` (decimal) in **negabinary** is written `11100` (its successive remainders are `0,0,1,1,1` :

12 / -2 = -6 | remainder 0 | -6*-2 = 12 |

-6 / -2 = 3 | remainder 0 | 3*-2 = -6 |

3 / -2 = -1 | remainder 1 | -1*-2 = 2 and 2+1 = 3 |

-1 / -2 = 1 | remainder 1 | 1*-2=-2 and -2+1 = -1 |

1 / -2 = 0 | remainder 1 | 0*-2 = 0 and 0+1 = 1 |

To convert a number from base $ -2 $ to base 10, apply numeric base change algorithms.

__Example:__ `110` (**negabinary**) is equivalent to 2 (base 10) $ 1 \times (-2)^2 + 1 \times (-2)^1 + 0 \times (-2)^0 = 2 $

In nega-binary, negative integers(with a minus sign in base 10) have an even number of bits, while the positive integers(with a plus sign in base 10) have an odd number of bits.

dCode retains ownership of the online "Négabinary" source code. Except explicit open source licence (indicated CC / Creative Commons / free), the "Négabinary" algorithm, the applet or snippet (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, translator), or the "Négabinary" functions (calculate, convert, solve, decrypt / encrypt, decipher / cipher, decode / encode, translate) written in any informatic language (Python, Java, PHP, C#, Javascript, Matlab, etc.) and all data download, script, copy-paste, or API access for "Négabinary" are not public, same for offline use on PC, tablet, iPhone or Android ! Remainder : dCode is free to use.

Please, check our dCode Discord community for help requests!

NB: for encrypted messages, test our automatic cipher identifier!

negabinary,base,binary,negative,bit,0,1,minus,sign

Source : https://www.dcode.fr/negabinary-system

© 2021 dCode — The ultimate 'toolkit' to solve every games / riddles / geocaching / CTF.

Feedback

▲
Thanks to your feedback and relevant comments, dCode has developed the best 'Négabinary' tool, so feel free to write! Thank you!