Join 137,208 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,292 people online right now. Registration is fast and FREE... Join Now!
what are the first and second algebra means? by the C syntax i can tell what it means NOT, OR, AND? but when it combines together to evaluate a solution i don't know what it means. thanks in advance.
My response is in the attached text. The editor doesn't like extra white space.
Edit: Fixed ! Typo. Thanks baavgai
i have some questions which are also in the attached file just in case the editor doesn't like white space. the info in your previous file make sense to me. thanks in advance.
Attached File(s) truthtable1.txt ( 2.53k )
Number of downloads: 33
There is almost never a reason to use inclusive OR(|). If fact, I'd forgotten it was even used in mathematics; such a notation is usually called "bitwise OR" by programmers and used to apply logic to bits in a value e.g. ( 5 | 3 ) == 7 which is ( 101 | 011 ) == 111.
Now to make your code into code. Here's an example:
cpp
/* ( Andrew && (!Nancy && !Andrew) ) || ( !Andrew && !(!Nancy && !Andrew) ) ( A && (!N && !A) ) || ( !A && !(!N && !A) ) can be further simplified NNA = (!N && !A) ( A && NNA ) || ( !A && !NNA ) */ int test1(int A, int N) { int NNA = (!N && !A); return (( A && NNA ) || ( !A && !NNA )); }
/* print all permutations */ void printAll() { int A, N, rownum = 0;
printf("\tA\tN\tT1\n"); for(A=0; A<2; A++) { for(N=0; N<2; N++) { printf("%d:\t%d\t%d\t%d\n", ++rownum, A, N, test1(A,N)); } } }
There is almost never a reason to use inclusive OR(|).
I completely disagree with this statement on so many levels. Bitwise operators are extremely useful for things like flags. Take Windows programming for example. Bitwise operators are used all over the place.
There is almost never a reason to use inclusive OR(|).
I completely disagree with this statement on so many levels. Bitwise operators are extremely useful for things like flags. Take Windows programming for example. Bitwise operators are used all over the place.
You, sir, have totally failed context.
The question on the table is: "3. if i interprete the above algebra into C code, do i use the normal logical OR(||) and logical AND(&&) or i have to use the inclusive OR(|) and inclusive AND(&)?"
My answer is, if you're doing a boolean operation, a standard AND and OR, an inclusive OR has extremely narrow use. Even if you had quoted the rest of my post, you may have caught onto that. However, how a programmer utilizes this function didn't seen apropos to the thread.