Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Ha, what a coincidence.

It won't work for decimal 10s complement numbers:

For x=10 we get

  1 + 10 + 100 + 1000 + 10000 + ... = -1/9
And -1 in a decimal computer is

  9 + 90 + 900 + 9000 + 90000 + …
so … OMG!

  9*(1 + 10 + 100 + 1000 + 10000 + ...) = 9*(-1/9) = -1


> Ha, what a coincidence.

> It won't work for decimal 10s complement numbers:

I don't get why you say this -- you go on to demonstrate the opposite?

This is just the other-side-of-the-decimal-point inverse of the well known 0.9999999... = 1 equality.

One of my favorite proofs for 0.9999... being equal to 1 goes like so: imagine subtracting it from 1. You'll get a number which has a 0 at every decimal place: 0.0000000.... Obviously, the number with a 0 in every decimal place is 0 itself.

Similarly, if you have your integer represented decimally as a bunch of coefficients (0 <= c < 10) of powers of 10, and all of the coefficients are 9, it's fairly straightforward to see that adding 1 will get you a new number for which all of the coefficients are 0. Since adding 1 to the original number gave us 0, we can treat the original number as -1.


I don't get why you say this

Just a narrative of my own experience thinking this through :-)

I thought "OMG" would tell you that, sorry.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: