Questions tagged [boolean-operations]

Boolean algebra is the algebra of truth values 0 and 1. The operations are usually taken to be conjunction ∧, disjunction ∨, and negation ¬, with constants 0 and 1.

Boolean algebra is the algebra of truth values 0 and 1. The operations are usually taken to be conjunction ∧, disjunction ∨, and negation ¬, with constants 0 and 1.

464 questions
22
votes
5 answers

Double pipes in JavaScript (||) throw error instead of evaluate as falsy

I read that the double pipes in JavaScript check to see if a variable is falsy, and that undefined is a falsy value in JavaScript, e.g. It means that if the value is falsey (e.g. 0, "", null, undefined (see also All falsey values in JavaScript)),…
Edward Tanguay
  • 176,854
  • 291
  • 683
  • 1,015
21
votes
8 answers

De Morgan's rules explained

Could you please explain the De Morgan's rules as simply as possible (e.g. to someone with only a secondary school mathematics background)?
Stefano Borini
  • 125,999
  • 87
  • 277
  • 404
21
votes
7 answers

What's the difference between the dual and the complement of a boolean expression?

Its the same thing right? Or is there a slight difference? I just wanna make sure I'm not misunderstanding anything.
18
votes
1 answer

Moving out before brackets with XOR

If I had the sum of products like z*a + z*b + z*c + ... + z*y, it would be possible to move the z factor, which is the same, out before brackets: z(a + b + c + ... y). I'd like to know how it is possible (if it is) to do the same trick if bitwise…
18
votes
7 answers

Using 'or die()' to stop on errors in PHP

Often in PHP, I see: $result = mysql_query($query) or die(); Coming from python, I know why this should work, because or returns the first value if it is true in a boolean context, and the second value otherwise (see this). But when I try the above…
rjmunro
  • 24,825
  • 18
  • 102
  • 130
16
votes
2 answers

How can i get count of number of rows that have boolean value true(or 1) in Room persistent database without using SELECT query?

I am working with Room persistent database in my project. I have a table in which there is a column for Boolean values as in 0 or 1, now i want the count of all Boolean values whose value is true (or 1). I know that i can achieve this using select…
15
votes
5 answers

Why are products called minterms and sums called maxterms?

Do they have a reason for doing so? I mean, in the sum of minterms, you look for the terms with the output 1; I don't get why they call it "minterms." Why not maxterms because 1 is well bigger than 0? Is there a reason behind this that I don't know?…
14
votes
5 answers

algorithm to find subset of large int array which matches boolean query

Say I have a large array of M 32 bit ints in which each value has no more than N bits set. Now I want to return the subset which matches the query Target AND Value == Target, i.e. values in which the targets bits appear set in the array's…
user51511
14
votes
4 answers

Why is 1 && 2 in C# false?

I got frustated with my other question. So i wrote up this example. In C the below is true. See demo int main() { printf("%d", 1 && 2); return 0; } Output: 1 In C#. It is FALSE. WHY is this false? Also i dont understand why i needed to create the…
user34537
14
votes
8 answers

OR, AND Operator

Newbie question. How to calculate the value of the formula A f B, where f - the binary function OR or AND?
Alexry
  • 507
  • 2
  • 5
  • 10
13
votes
3 answers

String compare on a bool

I'm pretty sure this is a simple fundamental flaw in my newb PHP knowledge, but I was surprised when the following happened: $result is TRUE... so why is it considered equal to the string "email"? I'm guessing this is because, technically, it's a…
Chuck Le Butt
  • 43,669
  • 58
  • 179
  • 268
12
votes
5 answers

Which JavaScript library can do boolean operations with bezier curves?

Does a Javascript library exist which can perform boolean operations on paths (bezier curves)? I know about Paper.js and Raphael.js, but both cannot perform these actions now.
philipp
  • 13,819
  • 10
  • 50
  • 87
11
votes
3 answers

Swift Boolean value

The attached screen shot says it all: I have a valid true Bool, I negate it with the bang operator, and (Xcode tells me) I have an invalid value. It appears that this "invalid" value does behave as if it were false. But really, wtf?
Andrew Duncan
  • 2,972
  • 2
  • 21
  • 44
10
votes
1 answer

Differences between .Bool, .so, ? and so

I’m trying to figure out what the differences are between the above-mentioned routines, and if statements like say $y.Bool; say $y.so; say ? $y; say so $y; would ever produce a different result. So far the only difference that is apparent to me is…
ozzy
  • 765
  • 3
  • 12
10
votes
2 answers

&&= in C#? (boolean expression)

Possible Duplicate: Why are there no ||= or &&= operators? By pure accident I found out today that a &= GetBool(); is NOT the same as a = a && GetBool(); I must have misunderstood that for years. In the first Example, "GetBool()" is executed…
Ole Albers
  • 7,645
  • 7
  • 56
  • 130
1
2
3
30 31