boolean-operations

Compute union of two arbitrary shapes

I'm working on an application, I need to be able to combine two overlapping arbitrary shapes as drawn by the user. This would be a Union operation on the two shapes. The resultant shape would be the silhouette of the two overlapping shapes. The shapes are stored as a sequence of points in a clockwise manner. Ideally I'd like an algorit...

deMorgan rules explained

Could you please explain the deMorgan rules as simply as possible (e.g. with a secondary school background) ? ...

More than operator in Boolean Logic (Logic gates)

Basically I have 2 unsigned 8-bit binary numbers and I need to use Boolean logic to find out which is larger and I can't for the life of me figure out where to start. Using Logic gates... Obivously I have to analyse each bit and find out which one is larger but how do I bring it all together? Say I had x and y and wanted to return true...

Why doesn't c++ have &&= or ||= for booleans?

Is there a "very bad thing" that can happen &&= and ||= were used as syntactic sugar for bool foo = foo && bar and bool foo = foo || bar? ...

Is it faster to use a complicated boolean to limit a ResultSet at the MySQL end or at the Java end?

Lets say I have a really big table filled with lots of data (say, enough not to fit comfortably in memory), and I want to analyze a subset of the rows. Is it generally faster to do: SELECT (column1, column2, ... , columnN) FROM table WHERE (some complicated boolean clause); and then use the ResultSet, or is it faster to do: SELECT (...

Variables combined with && and ||

What do the last lines mean? a=0; b=0; c=0; a && b++; c || b--; Can you vary this question to explain with more interesting example? ...

C# - OR and AND

Newbie question. How to calculate the value of the formula A f B, where f - the binary function OR or AND? Thanks for answers :) ...

How to avoid notice in php when one of the conditions is not true

I've notice that when one of the two conditions in a php if statement is not true. You get an undefined index notice for the statement that is not true. And the result in my case is a distorted web page. For example, this code: <?php session_start(); if (!isset($_SESSION['loginAdmin']) && ($_SESSION['loginAdmin'] != '')) { header ...

Why do most programming languages only have binary equality comparison operators?

In natural languages, we would say "some color is a primary color if the color is red, blue, or yellow." In every programming language I've seen, that translates into something like: isPrimaryColor = someColor == "Red" or someColor == "Blue" or someColor == "Yellow" Why isn't there a syntax that more closely matches the English sente...

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 technique in PHP in another context, for example something like: $name = "John Doe"; ...

How can I write like "x == either 1 or 2" in a programming language?

Possible Duplicate: Why do most programming languages only have binary equality comparison operators? I have had a simple question for a fairly long time--since I started learning programming languages. I'd like to write like "if x is either 1 or 2 => TRUE (otherwise FALSE)." But when I write it in a programming language, s...

Can someone please help me with some basic boolean minimization ?

Hey guys, Sorry to be annoying, but I am doing a little bit of work at the moment, and am trying to simplify the following piece of boolean algebra so that I can construct the circuit : A'.B'.C.D + A'.B.C.D' + A'.B.C.D + A.B'.C'.D + A.B'.C.D + A.B.C'.D + A.B.C.D' + A.B.C.D So far I have gotten it to : (C.D) + (B.C) + (A....

What simplifies an expression when `!` is applied to `&&` or `||`

5.121 ____ simplifies expression in which ! is applied to && or || This showed up on my quiz in Java. I have no idea what it is and it is not multiple choice. Could someone help me? ...