/* * bool-operations.c * * Author: Intel A80486DX2-66 * License: Unlicense */ #include #include #include #include #include #define BOOL_TO_STR_PADDED(x) ((x) ? "true " : "false") #define SHOW_BOOL_INT printf("boolean = %s (0x%d) | integer = %s (0x%d)\n", \ BOOL_TO_STR_PADDED(boolean), (int) boolean, \ BOOL_TO_STR_PADDED(integer), (int) integer) int main(void) { bool boolean = false; unsigned char integer = (unsigned char) boolean; printf("Loop:\n"); for (uint8_t i = 0; i < 3; i++) { SHOW_BOOL_INT; boolean++; integer++; } printf("\n* 2:\n"); boolean *= 2; integer *= 2; SHOW_BOOL_INT; printf("\n<< 1:\n"); boolean <<= 1; integer <<= 1; SHOW_BOOL_INT; printf("\n/ 2:\n"); boolean /= 2; integer /= 2; SHOW_BOOL_INT; printf("\n^ 0x10:\n"); boolean ^= 0x10; integer ^= 0x10; SHOW_BOOL_INT; printf("\n>> 1:\n"); boolean >>= 1; integer >>= 1; SHOW_BOOL_INT; return EXIT_SUCCESS; }