Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5001

Off topic discussion • Re: Boolean Algebra?

$
0
0
There 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
The notation is getting very confusing. Wikipedia writes
    WikipediaBoolean.png
    https://en.wikipedia.org/wiki/Boolean_algebra

    Unfortunately the meaning of ^ seems different than ^ in C.

    Statistics: Posted by ejolson — Thu Sep 12, 2024 8:39 pm



    Viewing all articles
    Browse latest Browse all 5001

    Trending Articles