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

> Meaning, I'm not sure what the developer was thinking

A 32bit integer is pretty much the default numeric type for the majority of programming tasks over the last 20 years. Even with 64bit CPUs, 32bit is still a common practice. Probably 99% of all programmers would make the same choice unless given specific requirements to support more than 2 billion values.



It's often not even an explicit choice, it's just default behavior.

Up until recently, Rails defaulted to 32 bit IDs, so there are a ton of apps out there that could have these issues, especially since Rails has always prided itself on providing sane defaults: https://github.com/rails/rails/pull/26266


> 99% of all programmers

Many dynamically typed languages have an automatic change from int to bigint rather than allowing overflow. For example, Python.


Others, like JS and Lua, just use doubles, meaning they'll never overflow - instead every 2 numbers start to be considered equal. Then a while after that every 4, etc. Not exactly optimal behavior when using incrementing IDs.


however, doubles represent integers accurately up to 53 bits. so that's still quite a lot before you run into that problem.




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

Search: