# Number Bases Stretch The Mind

Some of us might solve crossword puzzles or Sudoko games to exercise our minds, but [Nathan Nichols] plays with exotic number systems to keep the brain cells in shape. He wrote the Hanoi C99 library while in high school, implementing several of his favorites.

We have all been using decimal (base 10) and duodecimal (base 12, as in clocks) since before grade school. Us computer geeks are also adept at various computer-friendly systems like binary, octal, and hexadecimal. The true nerds among us will be familiar with systems like vigesimal (base 20 Mayan numerals) and sexagesimal (base 60 Babylonian numbers). We ourselves espoused the virtues of seximal (base 6) a couple of years ago. But if you really want to stretch your mind, take a dive into the weird number systems that [Nathan] has been exploring.

### Negabinary (`base -2`)

The lowest level of weirdness in the group, this one is almost normal. Its the same as binary, except the bit weights have alternating signs: `{ 1, -2, 4, -8, ... }`.

### Binarions (`base -1+i`)

Or `base -1+j` if you studied electrical engineering. The use of complex numbers as radices was proposed by Donald Knuth way back in 1955. We find it really hard to imagine this one being helpful.

### Fibonacci base

Numbers can also be represented by the summation of a sequence of Fibonacci numbers. Using this system, a number can sometimes be represented more than one way, so watch out.

### Stern-Brocot tree

A number is represented by its path down the Stern-Brocot tree. One feature of this system is that numbers can be exact. For example, the Stern-Brocot tree representation of one-third has a finite number of digits.

While [Nathan]’s library only performs conversion at input or output, we wonder if someone will take this further and implement an arithmetic unit inside an FPGA. Besides being a fun exercise, it would baffle someone casually trying to reverse engineer your secret calculations. Let us know of any strange number systems you have used or encountered.

## 22 thoughts on “Number Bases Stretch The Mind”

1. Fascinating, I’d often wondered in my earlier days just how bases could work beyond mere integers, food for thought especially in some aspects of theoretical physics where numeric outcomes could have more evident attributes re properties matching abstract paradigms eg black holes and problem of infinite time dilation in respect of rotation observance, thanks for posting :-)

FWIW. Some years ago I toyed with ‘primary’, bit like binary but each position corresponded to a prime number to power 1 (
at the first layer) Eg 9 being 2+7 the primary appears as binary as 10010, at first it seems superfluous as you can have different representations for the same equivalent number but, that turned out to be an advantage for certain types of cryptography especially when you then code overall in binary being somewhat arbitrary when you decide to mix primary & binary ;-)

Looking forward to comments, Happy New Year, it’s 01 01 2021 here in Australia

1. Ostracus says:

The kind of thinking that makes one a potential employee for the five eyes.

1. Amadeus87 says:

Sorry, but I fail to see any use in this for real world cryptanalysis.

2. Talks about “PrimNary” numbers in cryptography and finishes with a format-less “01 01 2021″…
Whats that? Trinary? little, big or retarded-endian? Are the whitespaces part of the encoding?
It can’t be a date, it’s not even mentioned as a discouraged format in “the” standard: https://xkcd.com/1179/
;-)

Happy new Year

2. Andy Pugh says:

I experimented with base Pi. It is very good for representing Pi and its (low) multiples and powers. And rather approximate for anything else.
It also means that the integers on the number line are not evenly spaced, but I have not worked out if that is a purely aesthetic problem.

1. I experimented with base Pi

Is that different than radians?

1. Andy Pugh says:

Yes, radians make sense.

The first few integers in base pi:

1
2
3
10.220122020…
10.220122020…
12.220122020…
20.202112000…

But pi=10, 2pi = 20
But pi/2 = 1.121120210

1. Andy Pugh says:

Sorry, copy-paste error. 5(dec) = 011.220122020…(pi)

3. Gravis says:

Shouldn’t negabinary include the value of 1? e.g. 0, 1, -2, 4, -8, 16, -32, 64

1. Jason Doege says:

I think it would be 1,-2,4,-8 … There is no 0 position in any base that I am aware of despite what was written above.

1. Chris Lott says:

Good catch, Jason. Corrected.

2. mike stone says:

You’re mixing values with positions.

Positional notation is sub-topic of polynomials and/or power series: the sequence is always:

S0b^0 + S1b^1 + S2b^2 + …

where Sn is a symbol and b is the base value. We just make things more complicated by writing the powers in descending order and restricting S to a set of integers smaller than the absolute value of the base.

Negabinary uses the symbols 0 and 1, and counting positive numbers goes 0=0, 1=1, 2=110(4+(-2)+0), 3=111, 4=100, 5=101, …

Counting from -5 to 5 goes -5=1111, -4=1100, -3=1101, -2=10, -1=11, 0=0, 1=1, 2=110, 3=111, 4=100, 5=101

4. Andrew Yeomans says:

In addition (as subtraction not needed) here are also number systems where the digits in each position differ from 0, 1, 2, 3…
For example, what I’ve heard called reverse duodecimal, where the digits are -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6. (Conventionally written with a bar over the digit, rather than a minus sign.)
You don’t have separate subtraction, since it’s easier to take the complement (i.e. change each digit to that of opposite sign) and then add. Note that some values have more than one representation.

5. MattAtHazmat says:

There is a book, “Hacker’s Delight” By Henry S. Warren, Jr. (ISBN 978-0-321-84268-8) that includes a chapter on unusual bases- the chapter is short, but includes some great discussion.

1. msrgh says:

I libgen-ed it, that’s quite an interesting book, thanks.

6. Jason Doege says:

It’s easy to espouse the benefits of alternate bases (than base 10). Base 2 and base 12 are both quite useful. Base sixty is really useful but would require a large number of symbols. Then we remember that conventional measure typically uses base 2 and base 12 and choose to bash the U.S., instead, going back to espousing base 10.

7. drenehtsral says:

Hah! I am so glad I am not the only person to play this mental game. One addition is observing how there are easy rules to know a multi-digit number is *not* prime in other systems than base 10 (by observing the least significant digit). For other bases there are similar rules (fewer for prime bases, more for highly composite bases).

8. Gregg Eshelman says:

Base 11 as used by the Psyclos in “Battlefield Earth” because they have 5 fingers on one hand and 6 on their other, dominant hand.

The book is a fun read, have never seen the movie. My paperback copy has “Soon to be a major motion picture!” on the cover. “Soon” turned out to be 14 years and “major” turned out to be “major flop”.

9. Old Guy says:

Clocks have nothing to do with Base 12, and wouldn’t it be Base 13? Might as well say Blackjack players are working in Base 21.

1. Foldi-One says:

While I can see your point, time and its many units can be considered as bases usefully sometimes.
And its definitely base 12 – when we say 12:15 (am/pm) we mean 00:15 – so you are counting ’12’ ,1, 2, .. .. ,11 then adding 1 to the am/pm column and starting at ’12’ again.

Which incidently is one way such counts can be useful if something will take an odd or even number of am/pm column to complete you know at a glance its going to finish during the day/night shift and at what hour.

1. NewCommentor1283 says:

fibonacci, grey-code…

in less then 180 days we all will know all numbering systems and thier true origins (among other things). we will also learn our place, and why it is what it is.

EDIT: actually, in 180 days we will be starting our journey together on a multi-year adjustment full of learning and understanding, what i said about numbering systems will only be a side-note missed andor lost on most people, most people will be too overwhelmed, even us techno-wizards might not be able to absorb enough tech-related info. and the idea of actually using these systems on a day-to-day basis _for_survival_ might be a stretch.

also, understanding another’s mindset may help understanding numbering systems developed by such.

PS: i know grey-code is a binary system, but it still backs up my point.

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.