
Negative Base - int_10h
https://en.wikipedia.org/wiki/Negative_base
======
msoucy
When I was part of an organization in college, part of the onboarding process
was that each applicant had to have a conversation and (possibly) do a "quest"
for each member. My standing quest was that I would write the first 12 or so
numbers in negabinary on my whiteboard, and have them determine the next few
numbers and explain what they meant. I had people sitting outside my room for
hours trying to figure it out. A few did do it, and normally had some
expletives for me afterward.

~~~
bhrgunatha
Looking at the table is bad enough, but I imagine most people looking would
think "Aaah binary" and convert to decimal: 1, 6, 7, 4, 5, 26, 27, 24, 25, 30,
31, 28... That's cruel :)

~~~
msoucy
I probably got a little too much sadistic pleasure out of it, yes...

However, I was always willing to answer nontrivial questions, and even convert
numbers to/from negabinary to help them. (The program used the Schroeppel2
implementation, to prevent them from getting too much of a clue if they
somehow managed to find its source code)

------
JdeBP
I remember when negative zero was labelled a hoax. (-:

* [https://en.wikipedia.org/w/index.php?title=-0&diff=25603603&...](https://en.wikipedia.org/w/index.php?title=-0&diff=25603603&oldid=25529350)

* [https://en.wikipedia.org/wiki/Wikipedia:Articles_for_deletio...](https://en.wikipedia.org/wiki/Wikipedia:Articles_for_deletion/-0)

~~~
pmarreck
Best way to represent nil, in my opinion ;)

Although it smells like a design flaw (which negabinary conveniently doesn't
have)

~~~
pphysch
Are there common languages where -0 != +0? Or are you implying that this would
be a good decision when creating a new language?

~~~
foxhill
basically every language with IEEE-754[1] compliance..!

[1] -
[https://en.m.wikipedia.org/wiki/IEEE_754](https://en.m.wikipedia.org/wiki/IEEE_754)

~~~
saagarjha
But only when imposing a total ordering.

~~~
foxhill
that’s not the case, in IEE754 floating point, zero is signed - i.e negative
and positive zero are distinct values

~~~
saagarjha
But the standard comparison operators don’t distinguish them.

------
rprospero
I think that's the first time I've ever seen someone use INTERCAL code to try
and explain a concept.

~~~
ainar-g
For those wondering, please do read the Wiki article[1]. It's amazing.

[1]
[https://en.wikipedia.org/wiki/INTERCAL](https://en.wikipedia.org/wiki/INTERCAL)

------
Sharlin
See also balanced ternary [1].

[1]
[https://en.wikipedia.org/wiki/Balanced_ternary](https://en.wikipedia.org/wiki/Balanced_ternary)

~~~
philbarr
Which you can use to solve the puzzle:

"You have 12 coins that all look exactly the same. One is counterfeit and is
either heavier or lighter than the other 11. With a balance beam scale,
isolate the counterfeit coin in three moves."

Any uses for Negative-base systems?

~~~
catpolice
Hoo, that's one of my favorite puzzles - there was a version of it on Brooklyn
Nine-Nine with no solution given, which ruined my sleep that night. I have a
theory that it's actually a little harder for programmers than for other
technically inclined people because the instinct to treat it as a kind of
binary search problem is really hard to shake.

~~~
TrinaryWorksToo
Is it not a binary search problem?

~~~
philbarr
Not really - you can reduce it to one but you don't quite have enough
information.

So I think it goes like this:

\- you have 12 coins, and each one has an equal chance of being heavier or
lighter than the others - so that's 24 possiblities

\- you have 3 moves, and the result of each move could be one side of the beam
goes down, one side goes up, or it balances. That means you can create a
system that identifies 3^3 = 27 outcomes. So far so good.

\- you need each of your outcomes to provide real information. if it was a
binary problem that means you're not really getting any information if the
beam balances

(bit sketchy on that last point, maybe someone can help with that)

~~~
wvlia5
"that means you're not really getting any information if the beam balances"

Wrong. If it was true, that would imply that the probability of it balancing
is 1, since the information you get is -log2(probability). Obviously the
probability of it balancing is lower than 1, so you do get information.

~~~
catpolice
You don't get any information if the probability of the beam balancing is
either 1 or 0. If you put everyone on the scale, the probability that it will
be balanced is 0 - you don't learn anything. So the trick is to exclude some
of the sample group in every measurement. You can use a binary search strategy
where you divide the coins into "on the scale" and "not on the scale" groups,
until you have a set of two that definitely contains the one you're searching
for (and then one more measurement will tell you which one of those two it is)
- but that strategy requires too many measurements, so you need to use more
information at each stage, and you can't throw out coins you've determined to
be non-counterfeit.

------
dvfjsdhgfv
Can anyone provide some examples of practical applications of this?

~~~
empath75
I can’t imagine there ever would be.

~~~
vinceguidry
I don't think anyone ever imagined a use for imaginary numbers either, but
those turned out to be quite useful for reducing dimensionality. Towards the
bottom of the article it states that Donald Knuth proposed imaginary base
numerical systems.

So this may eventually find a use, likely with higher-dimensional math.

~~~
ainar-g
It will be really funny if there is some bit of new, undiscovered physics,
that went undiscovered for so long just because it's best described using some
esoteric maths like complex base numbers.

Highly unlikely, but fun to think about.

~~~
throwaway37585
Are there any examples where the representation of a number matters in
physics?

~~~
jfoutz
I recall some effort in moving from imperial measurement to metric. Reality
itself does not care, but the math sure gets easier if you carefully select
units.

Actually, another neat example is analog vs digital computation. your models
can get very different answers. I recall some Mandelbrot guy talking about
that.

~~~
retzkek
See Gaussian (cgs) units for an example, compare Coulomb's law in cgs and SI:
[https://en.wikipedia.org/wiki/Gaussian_units#Unit_of_charge](https://en.wikipedia.org/wiki/Gaussian_units#Unit_of_charge)

------
dumbfoundded
Taken one step further, could you have irrational bases?

i^1 = i

i^2 = -1

i^3 = -i

i^4 = 1

~~~
pmarreck
[https://en.wikipedia.org/wiki/Complex-
base_system](https://en.wikipedia.org/wiki/Complex-base_system)

~~~
dumbfoundded
thank you!

------
joker3
How do you divide by numbers other than -2?

