News for hackers. Stuff that matters.
Re:Two's complement unexpectedly shows up in infinite series by pfortuny on Thursday October 20, 2022 @02:34PM (#33278796)
That is what happens when you play with divergent series… Fun stuff but not easy to explain (if at all).
Re:Two's complement unexpectedly shows up in infinite series by suremarc on Thursday October 20, 2022 @04:49PM (#33280494)
The infinite sum involving powers of two is actually true in the 2-adic integers.
Re:Two's complement unexpectedly shows up in infinite series by solresol on Thursday October 20, 2022 @08:46PM (#33282787)
And any of his other examples would work with powers-of-p if p is prime.

Those infinite series aren't divergent if you are measuring their size p-adically.

Gouvea's book actually goes through the things that RobAlni has just discovered.

Re:Two's complement unexpectedly shows up in infinite series by kevinventullo on Friday October 21, 2022 @01:35AM (#33284850)
Yep, and that last number is the 2-adic representation of -4/3.

It turns out a lot of ideas from calculus and real analysis carry over to the 2-adics, and this can lead to some interesting computational shortcuts since two’s complement is essentially native 2-adic arithmetic. I’ve blogged a bit about this here: https://kevinventullo.com/

Re:Two's complement unexpectedly shows up in infinite series by boonsuan on Friday October 21, 2022 @02:34AM (#33285170)
check out https://zjkmxy.github.io/posts/2021/11/twos-complement-2-adi... for a discussion of some relevant mathematics; cool stuff

there is also a lot of good stuff concerning such computational tricks and their relation with 2-adics in section 7.1.3 (Bitwise Tricks and Techniques) of volume 4A of The Art of Computer Programming: https://www-cs-faculty.stanford.edu/~knuth/fasc1a.ps.gz