The notation is getting very confusing. Wikipedia writesThere is no addition, subtraction, division or multiplication in boolean algebra. There is and, or and not. With the exclusive or being (A OR B) AND (NOT (A AND B)) as morphy_richards said above.Code:
#include <stdio.h>int main() { printf("0 | 0 = %b\n",0 | 0); printf("0 | 1 = %b\n",0 | 1); printf("1 | 0 = %b\n",1 | 0); printf("1 | 1 = %b\n",1 | 1); printf("\n"); printf("0 & 0 = %b\n",0 & 0); printf("0 & 1 = %b\n",0 & 1); printf("1 & 0 = %b\n",1 & 0); printf("1 & 1 = %b\n",1 & 1); printf("\n"); printf("0 ^ 0 = %b\n",0 ^ 0); printf("0 ^ 1 = %b\n",0 ^ 1); printf("1 ^ 0 = %b\n",1 ^ 0); printf("1 ^ 1 = %b\n",1 ^ 1); printf("\n"); printf("!0 = %b\n",!0); printf("!1 = %b\n",!1);}
Code:
knute@knute-XPS-8700:~$ ./boolean0 | 0 = 00 | 1 = 11 | 0 = 11 | 1 = 10 & 0 = 00 & 1 = 01 & 0 = 01 & 1 = 10 ^ 0 = 00 ^ 1 = 11 ^ 0 = 11 ^ 1 = 0!0 = 1!1 = 0
Unfortunately the meaning of ^ seems different than ^ in C.
Statistics: Posted by ejolson — Thu Sep 12, 2024 8:39 pm