A habit I've observed among programmers, and a habit I sometimes subconsciously exhibit myself, is to pick powers of two (or powers of two minus one) when defining a database schema, a data buffer, etc.Have you made the same observation? If I'm not being blatantly subjective, the follow-up questions are:Are there still valid reasons to use powers of two [minus one] in modern technologies?Assuming these habits are mostly vestiges of old technological limitations, I'm just wondering what different flavors of limitations there once were.Some potential reasons I can think of are data structure optimizations and addressing bits. I'm wondering what else was/is out there...
Picking powers of two for sizes/limits
data structures
Are there still valid reasons to use powers of two [minus one] in modern technologies?The power of two minus one is for 0-based indexing.  32768 items is 0 to 32767.  The size is 32768.  The last element is 32767.  This size vs. last element confuses people all the time.Physical memory is still managed in 16-byte paragraphs -- which are powers of two.  Disks still have blocks that are magical powers of two.  The actual number varies by filesystem and OS, but it's a magical power of two.You may achieve slightly better locality of reference and perhaps save a tiny bit of memory access time.  Compilers already do this memory alignment optimization for you.  With the multi-level cache on most modern processors, however, you'll have a hard time measuring the impact.Unless you're writing I/O drivers.  In which case, the device and the OS buffers will all involve lots of magical powers of 2 which you must use.  When writing I/O drivers, the magical powers of 2 are essential.For most purposes, however, I prefer to use magical powers of  12.  Why not?  Retry limits?  12 retries before we raise an exception.  Sample data?  12 sample rows from a large file for testing purposes.