Fun fact, not: In C, it's difficult to evaluate an expression in 8 bits. Integer promotion implicitly converts almost everything to int. Such as...

void f(uint8_t prev, uint8_t next) { if (next == (uint8_t) (prev + 1)) { /* cast needed to avoid promotion to int */ } }

Without casting, "prev + 1" is (at least) a 16-bit operation. The 16-bit PDP-11 was C's original platform, "int" is a reasonable default to write long expressions without casting. On 8-bit machines, like the common chips in #electronics, it can be a serious problem, slow 16-bit math can automagically appear out of nowhere. ​:woozy_baa:​

Follow

@niconiconi

What if you replaced the 1 with a `const uint8_t one {1};`

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.