2024-02-24 14:35:20 +05:30
|
|
|
/*
|
|
|
|
* bool-operations.c
|
|
|
|
*
|
|
|
|
* Author: Intel A80486DX2-66
|
2024-04-26 01:46:39 +05:30
|
|
|
* License: Unlicense
|
2024-02-24 14:35:20 +05:30
|
|
|
*/
|
|
|
|
|
|
|
|
#include <inttypes.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#define BOOL_TO_STR(x) ((x) ? "true" : "false")
|
|
|
|
#define SHOW_BOOL printf("boolean = %s\t(0x%" PRIxMAX ")\n", \
|
|
|
|
BOOL_TO_STR(boolean), \
|
|
|
|
(uintmax_t) boolean)
|
|
|
|
|
2024-04-22 02:14:56 +05:30
|
|
|
int main(void) {
|
2024-02-24 14:35:20 +05:30
|
|
|
bool boolean = false;
|
|
|
|
printf("Loop:\n");
|
|
|
|
for (uint8_t i = 0; i < 3; i++) {
|
|
|
|
SHOW_BOOL;
|
|
|
|
boolean++;
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("\n* 2:\n");
|
|
|
|
boolean *= 2;
|
|
|
|
SHOW_BOOL;
|
|
|
|
|
|
|
|
printf("\n<< 1:\n");
|
|
|
|
boolean <<= 1;
|
|
|
|
SHOW_BOOL;
|
|
|
|
|
|
|
|
printf("\n/ 2:\n");
|
|
|
|
boolean /= 2;
|
|
|
|
SHOW_BOOL;
|
|
|
|
|
|
|
|
printf("\n^ 0x10:\n");
|
|
|
|
boolean ^= 0x10;
|
|
|
|
SHOW_BOOL;
|
|
|
|
|
|
|
|
printf("\n>> 1:\n");
|
|
|
|
boolean >>= 1;
|
|
|
|
SHOW_BOOL;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|