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:
@robryk@qoto.org Exactly. But an explicitly cast like this is easily recognized by nearly all compilers to output 8-bit instructions, you don't need a powerful optimizer to do this transformation.