Hacker News new | ask | show | jobs
by hohokus 900 days ago
hmm -- https://looo.lol/?x=65536
3 comments

None of the powers of two work:

https://looo.lol/?x=1 (I like the “Binary math can seem hard, but it's actually quite simple.”)

https://looo.lol/?x=2

https://looo.lol/?x=4

There are only two hard things in programming:

1) off by one errors

(in this case it comes in the annoying form of messed up floor/ceil calculations)

This is because for any n-bit number, the maximum value is 2^n - 1, e.g. 2^8 - 1 = 255

But the number of values is just 2^n, because that includes zero.