FAQ Database Discussion Community

## how do i query a field in mongodb with a boolean value and return a boolean whether its true or false

javascript,mongodb,meteor,mongodb-query,boolean-logic
check my simple collection: {_id: "01", name: "Jimmy", canDrive: false } What I want to do once a document is found, is to manipulate a DOM and show a <div class="driving-tutorial> if the field canDrive value is false and hide it if the value is true like this in meteor:...

## Convert SOP to POS in Boolean Algebra

boolean-logic
Hi I'm trying to convert SOP (Sum of Products) to POS (Product of Sums). The question is like this. ABC +AB'C'+AB'C+ABC'+A'B'C I just want to know some technic how to convert SOP to POS? I got thus like this but I can't find any more. ABC +AB'C'+AB'C+ABC'+A'B'C =A(BC +B'C'+B'C+BC')+A'B'C =A(1+1)+A'B'C...

## Why does ReSharper tell me this expression is always true?

c#,resharper,boolean-logic,roslyn
I have the following code which will tell me whether or not a certain property is used elsewhere in the code. The idea behind this is to verify whether a property with a private setter can be made readonly. There are multiple gotchas here but the major ones are that...

## Converting binary decision diagram to truth table

algorithm,data-structures,implementation,boolean-logic,binary-decision-diagram
Given a binary decision diagram, how do I convert it into a truth table? What is the exact algorithm for it ? I have been trying this for a long time. Here is an example which one can follow: Source: Wikipedia. (The dotted edges represent 0; solid edges, 1.)...

## Among several given ways to test a string against two possible values using strcmp, is one of them an obvious choice?

c,performance,if-statement,boolean-logic,strcmp
I wish to test a string against "y" and "yes" and if it is either, do something. (Well, not really but this is the equivalent of the real code.) The following three ways of doing the test in C are logically equivalent. I am curious how more experienced programmers would...

## switch between true and false state

jquery,boolean-logic,boolean-expression
I have an object representing a player and let us say 2 players //create a player object function player(name,state,score) { this.name = name; this.state = state; this.score = score; } var players = [ new player('player1',true,0), new player('player2',false,0) ]; so I want the players to make a move one after...

## why do pandas comparison operators not align on index?

python,indexing,pandas,boolean-logic
I have been tracking down an elusive bug in a complex application which relies heavily on pandas, and finally traced it to a Series ordering issue. Series with differently ordered - but compatible - indexes are not automatically aligned by comparison operators. This is different behavior than for arithmetic operators,...

## Why does (true && {}) evaluate to {}, but ({} && true) evaluates to true? [duplicate]

javascript,boolean,boolean-logic
This question already has an answer here: Behaviour of and operator in javascript 1 answer As the title said, I can't quite understand why (true && {}) gives me {}, but the reverse is not the same. Edit: As a followup, since I'm using a boolean operator, why does...

## How to format code so while loop is triggered C

c,while-loop,formatting,boolean-logic
So I have two while loops. The outer most one does not loop back the way I want it to. I first tried: #define true 1 #define false 0 But then set it to what I did below. My problem is that when I run the program, it terminates after...

## Logical Boolean Negation Operator Precedence and Association

php,boolean-logic,negation,boolean-algebra
here's my first question(s) on StackOverflow, and as such I imagine it has been asked here before, but everything I type into the search bar gives me different questions. (Or sometimes "no" results at all!) I am learning on w3Schools, but I saw this seemingly simple code snippet which stirred...

## Grouping conditions with parentheses not working

sql,postgresql,boolean-logic,operator-precedence
I am trying to use an SQL query in Postgres that looks like this: UPDATE gamebet SET points = 15 WHERE game = 8 AND "scoreT1" > "scoreT2" AND "scoreT1" - "scoreT2" != 1 AND ("scoreT1" != 1 AND "scoreT2" != 0) It should update the scores of some bets...

## Python coding bat warmup returning unexpected True

python,boolean-logic
Was attempting the following problem: The parameter weekday is True if it is a weekday, and the parameter vacation is True if we are on vacation. We sleep in if it is not a weekday or we're on vacation. Return True if we sleep in. sleep_in(False, False) → True sleep_in(True,...

## Java is by passing loop and code running ahead?

I never seen Java act this way, but it seems to be bypassing my loop. I'm using slick2D with 2 classes. Graphic public class graphic extends BasicGame { public static int POS1 = 100; public static int POS2 = 100; public static String text = "f"; public static boolean test...

## Boolean negation

boolean-logic
One of my exam questions reads: ! ( ! ( a != b) && ( b > 7 ) ) The choices: a) (a != b) || (b < 7) b) (a != b) || (b <= 7) c) (a == b) || (b <= 7) d) (a != b)...

## Sql query to read the hardcoded values in oracle 11gR2

sql,oracle,boolean-logic
TABLE1 ID DEPT_Inclusion(AND) DEPT_Exclusion(OR) E1 3 AND 4 AND 5 AND 6 AND 7 1 OR 2 E2 (1 OR 2) AND 3 4 OR 5 E3 1 AND 2 AND (3 OR 4) AND 5 6 OR 7 E4 1 AND 3 AND 5 2 OR (3 AND 4)...

## Finding the best 3 elements in a collection in Drools

drools,boolean-logic,rules
Let's say I have some numbers in the working memory, and in a rule I need to check that the 3 higher numbers have a property (that they are all odd for example), how would you write that in pure Drools? I could collect all the numbers in a list...

## if statement does not seem to ever evaluate false

java,if-statement,boolean-logic
Goal: User uploads an image, a validator checks to make sure it is an image file the user uploaded, returns message if it is not an image, doesn't if it is. Issue: When Upload button is clicked, regardless of whether the uploaded file is an image or not an image,...

## Result of IF statement nested in WHILE loop confusing me (Javascript)

javascript,loops,if-statement,while-loop,boolean-logic
Here's my full code (javascript): var products = ["Choo Choo Chocolate", "Icy Mint", "Cake Batter", "Bubblegum"]; var hasBubbleGum = [false, false, false, true]; var i = 0; while (i < hasBubbleGum.length) { if (hasBubbleGum[i]) { console.log(products[i] + " contains bubblegum"); } i = i + 1; } This code returns...

## How to incorporate a boolean in a method JAVA

java,boolean-logic
I having a hard time getting the right output because i dont know how boolean exactly works inside a method. I have an arraylist and I'm check for any duplicates in the arraylist Here's my code public void rentOneInstrument(List<Instrument> instrumentList){ String a=""; String b=""; boolean found = false; for (int...

## Finding `n1` TRUEs wrapped in between two `n2` FALSEs, the whole thing wrapped in between `n3` TRUEs, etc

r,search,boolean,boolean-logic,boolean-operations
From a sequence of TRUEs and falses, I wanted to make a function that returns TRUE whether there is a series of at least n1 TRUEs somewhere in the sequence. Here is that function: fun_1 = function(TFvec, n1){ nbT = 0 solution = -1 for (i in 1:length(x)){ if (x[i]){...

## What is the difference beetwen “not” and “!” in Ruby except the precedence?

ruby,boolean-logic
I've have wrote a little exercise on Ruby. It is from this course. It shifts characters in the sting into n position. I get different results in my code here if !char =~/\W/ depending on what I've used ! or not keyword. In first case it do not change string...

## How many nand gates does a computer actually need to operate?

hardware,boolean-logic,computer-architecture
Sorry if this is a noob question, but at first I was thinking that logic gates were much smaller than they actually are: https://www.google.com/search?q=nand+gates#q=nand+gates&tbm=shop So my question is, how many logic gates (similar to the one above) does a computer actually need to operate? Since this number must be somewhat...

## how can I display the information in a textbox from this code?

c#,textbox,return-value,boolean-logic,registrykey
I am working on a small tool that essentially looks for multiple installed software on the host computer. I found a piece of code that a much better programmer put together in C#, however, I'm wondering two things. 1. What do I replace with the registry title to search installed...

## Verilog test bench compiles but simulate stops at 700 ticks

verilog,boolean-logic
First off please forgive any spelling mistakes, English is not my first language. For a project I'm trying to simulate some "basic" logic using iverilog. Currently I have a simulation that for some reason hangs on the third downward flank of the clock signal. The test bench compiles fine however...

## What are the basic steps from a hardware circuit to a transitionssystem

logic,computer-science,transitions,boolean-logic
What are the basic steps when I want to get a hardware circuit into a transitionssystem? I don't get the arrows between the nodes. The arrows from/to the same node are simple. But How do I get the arrows between node {r} and node {x,r,y} for example? and what can...

## Logical operations using Named Ranges within Excel

excel,excel-2010,boolean-logic,named-ranges
I came across this issue when trying to use better named referenced in my spreadsheet Take this example using Boolean logic Column A has the named range "Include1" Column B has the named range "Include2" The formulas are: What I see is that if I use the named range directly...