/* * 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; puts("Loop:"); for (uint8_t i = 0; i < 3; i++) { SHOW_BOOL_INT; boolean++; integer++; } puts("\n* 2:"); boolean *= 2; integer *= 2; SHOW_BOOL_INT; puts("\n<< 1:"); boolean <<= 1; integer <<= 1; SHOW_BOOL_INT; puts("\n/ 2:"); boolean /= 2; integer /= 2; SHOW_BOOL_INT; puts("\n^ 0x10:"); boolean ^= 0x10; integer ^= 0x10; SHOW_BOOL_INT; puts("\n>> 1:"); boolean >>= 1; integer >>= 1; SHOW_BOOL_INT; return EXIT_SUCCESS; }