Anyone happen to have a truth table sourc-code? 
Author Message
 Anyone happen to have a truth table sourc-code?

I want to study how truth table works in C.

--
-
<-------------------FantasyZ----------------------->

 ooO_(_)_Ooo_______________
__|_____|_____|_____|_____|__
_|_Born_|__to__|__be__|_Free__-|



Sat, 21 Dec 2002 03:00:00 GMT  
 Anyone happen to have a truth table sourc-code?

Quote:

> I want to study how truth table works in C.

Care to elaborate?  I can think of several ways of implementing a
truth right off the top of my head.
--
"Give me a couple of years and a large research grant,
and I'll give you a receipt." --Richard Heathfield


Sat, 21 Dec 2002 03:00:00 GMT  
 Anyone happen to have a truth table sourc-code?


Quote:
> I want to study how truth table works in C.

#include <stdio.h>

#define PRINT_TRUTH(op,op_name) printf("OP:  %s\n",op_name);\
printf("0 %s 0 = %i\n",op_name,0 op 0);\
printf("0 %s 1 = %i\n",op_name,0 op 1);\
printf("1 %s 0 = %i\n",op_name,1 op 0);\
printf("1 %s 1 = %i\n\n",op_name,1 op 1)

int main()
{
PRINT_TRUTH(&&,"AND");
PRINT_TRUTH(||,"OR");
PRINT_TRUTH(^,"EOR");

return 0;

Quote:
}



Sun, 22 Dec 2002 03:00:00 GMT  
 Anyone happen to have a truth table sourc-code?

Quote:

> > I want to study how truth table works in C.

> #include <stdio.h>

> #define PRINT_TRUTH(op,op_name) printf("OP:  %s\n",op_name);\
> printf("0 %s 0 = %i\n",op_name,0 op 0);\
> printf("0 %s 1 = %i\n",op_name,0 op 1);\
> printf("1 %s 0 = %i\n",op_name,1 op 0);\
> printf("1 %s 1 = %i\n\n",op_name,1 op 1)

> int main()
> {
> PRINT_TRUTH(&&,"AND");
> PRINT_TRUTH(||,"OR");
> PRINT_TRUTH(^,"EOR");

> return 0;
> }

Bzzzzzzzzzzzzzz!!!!!!!!!

int main (void) {
  int i= 0;
  if (i) PRINT_TRUTH(&&, "AND");
  return 0;

Quote:
}

Rgis


Sun, 22 Dec 2002 03:00:00 GMT  
 Anyone happen to have a truth table sourc-code?

Quote:


> > > I want to study how truth table works in C.

> > #include <stdio.h>

> > #define PRINT_TRUTH(op,op_name) printf("OP:  %s\n",op_name);\
> > printf("0 %s 0 = %i\n",op_name,0 op 0);\
> > printf("0 %s 1 = %i\n",op_name,0 op 1);\
> > printf("1 %s 0 = %i\n",op_name,1 op 0);\
> > printf("1 %s 1 = %i\n\n",op_name,1 op 1)

Note that "^" is a bitwise operator
whereas "&&" "||" are logical operators,
so a truth table for "^" has
2 to the power of (CHAR_BIT*sizeof(an_integer_type)) entries
and not only 4.

Moreover, since non-zero means true we have
2 ^ 4 == binary(010) ^ binary(100) == binary (110) == 6
that is
true ^ true == true
whereas it would have yield false if the operator was logical.

Question:
in a one-complement machine is the result of
(1 - 1) ^ 0    
predictable ?

Rgis



Sun, 22 Dec 2002 03:00:00 GMT  
 Anyone happen to have a truth table sourc-code?
wow, surpise me with such responses

erm, it is about entering a string containing the expression to be
evaluated, e.g. A.B+C, from here is evaluate the answer whether is it 1 or
0.

You see i don't know the mathematic formulate to be written in C
<pss, yeah i know u guys can think right of your head... but...i can't ;o)
--
-
<-------------------FantasyZ----------------------->

 ooO_(_)_Ooo_______________
__|_____|_____|_____|_____|__
_|_Born_|__to__|__be__|_Free__-|


Quote:

> > I want to study how truth table works in C.

> Care to elaborate?  I can think of several ways of implementing a
> truth right off the top of my head.
> --
> "Give me a couple of years and a large research grant,
> and I'll give you a receipt." --Richard Heathfield



Sun, 22 Dec 2002 03:00:00 GMT  
 Anyone happen to have a truth table sourc-code?

: wow, surpise me with such responses

: erm, it is about entering a string containing the expression to be
: evaluated, e.g. A.B+C, from here is evaluate the answer whether is it 1 or
: 0.

: You see i don't know the mathematic formulate to be written in C
: <pss, yeah i know u guys can think right of your head... but...i can't ;o)

ANSI C doesn't provide any functions to calculate the value of a
mathematical expression supplied as a string. You have to write the
calculation functions yourself. It's mostly trivial, you just have to
put operands on one stack, operators on another, and when you're
finished, you're left with one value in the operands stack, that's the
result. I don't have the time or space to make a full document about
the calculation functions here.

--

| Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #80 D+ ADA N+++ |
| http://www.helsinki.fi/~palaste       W++ B OP+                     |
\----------------------------------------- Finland rules! ------------/

"You could take his life and..."
   - Mirja Tolsa



Sun, 22 Dec 2002 03:00:00 GMT  
 Anyone happen to have a truth table sourc-code?
 > Question:
 > in a one-complement machine is the result of
 > (1 - 1) ^ 0    
 > predictable ?

If you want to know whether the result is all bits set or all bits clear,
no, that is not predictable across all ones-complement machines.  I have
worked with a machine were (1-1) would be -0 and with a machine were it
would be +0.
--
dik t. winter, cwi, kruislaan 413, 1098 sj  amsterdam, nederland, +31205924131
home: bovenover 215, 1025 jn  amsterdam, nederland; http://www.cwi.nl/~dik/



Sun, 22 Dec 2002 03:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Anyone happen to know about truth table?

2. truth tables

3. truth table

4. Anyone knkow what's happening here?

5. Is anyone else having this problem with VC6?

6. Anyone having SQL 7 problems w/VC++ ?

7. Anyone else having problems with Outlook Express and Microsoft groups

8. Anyone having problems with wnaspi32.dll???

9. Deleteing 10% of records in a huge table having no index

10. Getting an embedded table relationship without having to go via the hyperlink

11. Looking for SPRINTF sourc

12. Woldfenstein 3D sourc

 

 
Powered by phpBB® Forum Software