Questions tagged [boolean-logic]

An algebraic system developed by George Boole. Uses operations such as "And", "Or" and "Not" on Binary True/False values. It may be used to accomplish complex tasks.

Boolean logic is a two-element boolean algebra, a formalism that gives algebraic semantics for classical propositional logic.

1775 questions
0
votes
2 answers

Ternary logic for result (not about ternary operator)

I have a code (Java for example): boolean A(...){ if (...) return true; else return false; } void C(...){ if (A) {doSomeThing();} else {doNothing();} } But logic is changed and today i need return 3…
0
votes
4 answers

Evaluation order of statements separated by an OR operator

Here is my if statement: AND a Fiddle: http://jsfiddle.net/setMa/ $('#addamenity').click(function () { var id = $('.editblock').find('#id').val(); var amenity = $("#amenity").val(); var dataString = { id: id, amenity:…
Burning Hippo
  • 787
  • 1
  • 20
  • 47
0
votes
3 answers

PHP combined operator for &&?

I have code like this: $finalResult = true; $finalResult = $finalResult && function_01(); // some code here $finalResult = $finalResult && function_02(); // some many lines of code here $finalResult = $finalResult && function_XX(); And I'm…
Enriqe
  • 567
  • 1
  • 6
  • 22
0
votes
2 answers

Boolean logic confusion

I do not fully understand the difference between a bitwise operation and a logical operation. Please see the bitwise operation below: x=7 and 15 I understand that x will equal 7 in this case after inspecting each bit individually. How does…
w0051977
  • 15,099
  • 32
  • 152
  • 329
0
votes
2 answers

Boolean gate logic

I've got this expression and I believe I have the circuit drawn out correctly however I think the truth table for it is a trick question. There is 4 inputs and 2 of them are A and the other 2 are B and C. Here is what I've drawn out: Here's what…
Rapidz
  • 19
  • 5
0
votes
1 answer

boolean if and else statement to toggle button

I am receiving a True/False statement called favIcon, that is responsible for a button state. This button toggles from "active to "disabled", and behaves similar to a "facebook like button": on page load, if favIcon is true it shows the button…
0
votes
4 answers

Is there a reason to use &= rather than just = on a boolean?

I ran across some code today that was checking a number of error conditions. A single boolean was used all the way through, but instead of reassigning it every time with an =, it was reassigned with an &= resulting in a bit wise ANDing of the the…
GBleaney
  • 2,096
  • 2
  • 22
  • 40
0
votes
2 answers

More efficient boolean algebra for conditions comparing wild cards

In casino slot games you often have a Wild game piece. What would be a good way of including this mechanic into comparing with 2 other pieces? e.g. given 3 game pieces [Cherry][Cherry][Joker] would be a match. The code I'm using right now seems…
ferr
  • 1,137
  • 3
  • 12
  • 28
0
votes
1 answer

My unit checking variable isn't reading the input properly, when I put cm in as input the program sends the boolean to the else

when I enter cm into the uCheck variable the program prints the string in the else condition uCheck=input(print('Unit?')) #<--I enter 'cm' here if uCheck=='nm': Wave=Wave if uCheck=='cm': #<--it seems to skip this boolean …
user2446048
  • 15
  • 1
  • 5
0
votes
3 answers

Switching a logic gate on or off

if I have an "AND gate" with three inputs "A,B and control line C" can I control switching AND gate on or off .. just like this if C == 1 then AND gates works with input A,B if C==0 then nothing happens can this be done by any method ??
0
votes
1 answer

MIPS OR with negative numbers

So what happens when you OR two negative numbers? Is it ever guaranteed that whenever you OR a positive with a negative, the result will be positive?
Bondolin
  • 2,793
  • 7
  • 34
  • 62
0
votes
3 answers

While function how do I use both & and |

I am a total noob so when I explain simple stuff, it's not because I'm retarded, it's just that I want to know if I think wrong or right. I have 2 variables at first, x1 and y1. I put them in a while () like this while ( y1<0 || y1>500 || x1<0 ||…
user2779497
  • 77
  • 1
  • 3
  • 9
0
votes
1 answer

Pythonic way to make string dependend on type of variable

In a text file I have to write values, and next to each value either "NUMERIC" if the value's type is int or float, or "NOMINAL", if the type is str. I know that this could be solved by an if statement, but I would be pleased to use a more elegant…
aldorado
  • 4,394
  • 10
  • 35
  • 46
0
votes
1 answer

a combinational circuit that accepts a 4-bit number and generates a 3-bit binary number output that approximates the square root of the number

Design a combinational circuit that accepts a 4-bit number and generates a 3-bit binary number output that approximates the square root of the number. For example, if the square root is 3.5 or larger, give a result of 4. If the square root is < 3.5…
JustAStudent
  • 99
  • 1
  • 5
  • 10
0
votes
0 answers

Boolean Algebra-Simplification Assistance Needed

I have to show that (!P.!Q+R)(!Q+P.!R) => !Q by simplifying it using De Morgan's Laws. Here is what I did but I'm not sure it's right. (!P.!Q + R)(!Q + P.!R) => !Q (!P + !Q + R)(!Q + P.!R) !P.!Q + !P.P.!R + !Q.!Q + !Q.P.!R + R.!Q + R.P.!R !P.!Q + 0…
1 2 3
99
100