we talked last week about what can go wrong with floating point numbers, so -- what can go wrong when using integers?

so far I have:

* 32 bit integers are smaller than you think (they only go up to 4 billion!)
* overflow
* sometimes you need to switch the byte order
* ?? (maybe something about shift / bitwise operations? not sure what can go wrong with that exactly)

I'd especially love real-world examples of things that have gone wrong, if you have them!

@b0rk this is the classic real world example of integer overlow https://ai.googleblog.com/2006/06/extra-extra-read-all-about-it-nearly.html
Extra, Extra - Read All About It: Nearly All Binary Searches and Mergesorts are Broken

@b0rk on a similar note, there's an hour long talk on "why implementing std::midpoint()" is very tricky https://www.youtube.com/watch?v=sBtAGxBh-XI
CppCon 2019: Marshall Clow “std::midpoint? How Hard Could it Be?”

YouTube

@b0rk the only thing that comes up for me regularly is that modulus doesn't work the same way across languages, when you ask for the mod of a negative number

which leads to "what the hell is even happening" type bugs

@b0rk or how floor division can trip people up with negative numbers, as it rounds to the smaller number

>>> -3.5 //2
-2.0
>>> 3.5 //2
1.0

@tef @b0rk exactly this! It's not modulus, it's remainder, usually