Tuesday, July 28, 2009

How is Boolean logic used in computer programming?

All computer programming eventually comes down to Boolean logic: True or false. All computer memory really records is whether each bit is on or off -- true or false -- so everything your computer does is ultimately Boolean.





So, all variables, all control structures, all procedures, everything is basically changing bits of memory either on or off.

How is Boolean logic used in computer programming?
true and false answers
Reply:it is anything that evaluates as TRUE or FALSE, YES or NO, RIGHT or WRONG, 1 or 0
Reply:You can use the binary instructions in a programming language to do a variety of tasks. Here's some of them:





Bit shifting a number can multiply or divide a number by 2, like this:


00000010 = 2 decimal


shift left once


00000100 = 4 decimal





You can use bits as flags (some Windows functions do this). For example, a double-word has 32 bits in it, and so it can signal 32 possible settings or options for a function. You can set bits with the OR operator.





If you need to see if a certain bit in a dword is set to 1, you can use the AND operator to isolate the bit that you're looking for.





In Assembly language you can use the XOR operator to zero out a CPU register or memory address. You can also test if a CPU register or memory address is zero with the OR operator.
Reply:I know about boolean variables that only accept true or false as a value. When you code with a boolean is like turning the lights on/off to ensure you achieve the desired effect.





For example, cameleon buttons show multiple captions like "add", "delete", "exit", and "ok"





If you want to show the "Add" in the caption of the button you switch the lights on and your code works in a select case of an nested if.





Don't know if that is what you were asking though!





Cheers!
Reply:If you look inside the computer, you will find that inside the chips are circuits which uses different conditions called gates that results to different boolean expressions. The computer uses the following conditions:


AND


OR


XOR


XNOR


NAND


RAND


INVERTER


and others...


If a chip or IC (integrated circuit) has an AND logic circuit in it and it accepts 2 binary digits, the logic table will be like this:


1st input 2nd input result in binary


1 1 = 1


1 0 = 0


0 1 = 0


0 0 = 0


go here for more details:


http://scitec.uwichill.edu.bb/cmp/online...

flower arrangement

No comments:

Post a Comment