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

> Storing those 4 values takes ~29 bits.

Just storing those 4 values in 4 bits is more efficient.

Checking that a bit is set is also a simple AND + CMP. Which beats out a DIV + CMP.

Sorry I just had not considered this isn't common knowledge outside C or C++ land.



> Just storing those 4 values in 4 bits is more efficient.

That doesn't really work for version numbers > 1. They're not just flags.


How do you store a version number in a single bit?


Well the bit n represents the version n, if this bit is at 1, this version is supported, otherwise it's not.


A few bits per value (depending how big you predict they will get). One bit per value means you can only increment version of each function once :)




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

Search: