Hacker News new | past | comments | ask | show | jobs | submit login

It is just very finicky, with myriad edge cases easy to get wrong, and even easier to neglect to have complete tests for. Each target CPU design and version has quirks. Many involve sign extension.



Extracting a subrange of bits and shifting them to the beginning is not exactly rocket science.


Experience indicates otherwise.

If you must use bit fields, make them unsigned. Bugs love to hide under signed bit fields.


That makes sense, looking at how signed arithmetic works on different architectures it would feel strange to use signed bitfields.

Unsigned bitfields are a nice way to get modular arithmetic with n bits without syntactic clutter.


"Unsigned bitfields are a nice ..."

Appear to be. Are, when all the stars align. Are not in fact, often enough that you are issued a red warning you may ignore if you are insulated from all consequences.




Join us for AI Startup School this June 16-17 in San Francisco!

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

Search: