boolean

refactoring boolean equation

Let's say you have a Boolean rule/expression like so (A OR B) AND (D OR E) AND F You want to convert it into as many AND only expressions as possible, like so A AND D AND F A AND E AND F B AND D AND F B AND E AND F You are just reducing the OR's so it becomes (A AND D AND F) OR (A AND E AND F) OR (...) Is there a property in Boo...

What is the third boolean state in java?

While I know that by definition a boolean consists of only two states, true or false. I was wondering what value does a boolean have before it is initialized with one of these states. ...

ActiveRecord dynamic attribute-based finders with Union Logic?

I want 'logical OR' dynamic finders in ActiveRecord. Anybody seen such a thing? So in the spirit of something like this.. User.find_by_name_and_email("foo", "[email protected]") .. you could do stuff like this.. User.find_by_username_or_email(user_input) ...

Checking database for NULL boolean value

I have a field in a table that is boolean, a range of records have no value (not true or false). How do I write my SQL statement to find these? I have tried the following SQL statements without success: 1) SELECT * FROM table WHERE field = NULL 2) SELECT * FROM table WHERE field != TRUE AND field != FALSE Any help would be greatly ap...

Delphi: No VarIsBoolean( )-function?

In variants.pas, there is several VarIsXXX( )-functions for type-checking a variant. There is no VarIsBoolean( ), though. What's your preferred way of checking if a variant is of type boolean? ...

Why C++ allows arithmetic or enumeration values to be implicitly converted to boolean?

C++ standard says in section 4.12, An rvalue of arithmetic, enumeration, pointer, or pointer to member type can be converted to an rvalue of type bool. A zero value, null pointer value, or null member pointer value is converted to false any other value is converted to true. Which means that the following code is valid, if(5) std::co...

How do I use boolean variables in Perl?

I have tried: $var = false; $var = FALSE; $var = False; None of these work. I get the error message Bareword "false" not allowed while "strict subs" is in use. ...

Flex and Bison Associativity Problem

Using Flex and Bison, I have a grammar specification for a boolean query language, which supports logical "and", "or", and "not" operations, as well as nested subexpressions using "()". All was well until I noticed that queries like "A and B or C and D" which I'd like parsed as "(A & B) | (C & D)" was actually being interpreted as "A & ...

Is it possible to turn off support for "and" / "or" boolean operator usage in gcc?

GCC seems to allow "and" / "or" to be used instead of "&&" / "||" in C++ code; however, as I expected, many compilers (notably MSVC 7) do not support this. The fact that GCC allows this has caused some annoyances for us in that we have different developers working on the same code base on multiple platforms and occasionally, these "error...

Does "if ([bool] == true)" require one more step than "if ([bool])"?

This is a purely pedantic question, to sate my own curiosity. I tend to go with the latter option in the question (so: if (boolCheck) { ... }), while a coworker always writes the former (if (boolCheck == true) { ... }). I always kind of teased him about it, and he always explained it as an old habit from when he was first starting progr...

Boolean value of objects in Python

As we know, Python has boolean values for objects: If a class has a length attribute, every instance of it which happens to have length 0 will be evaluated as a boolean False (for example, the empty list). In fact, every iterable, empty custom object is evaluated as False if it appears in boolean expression. Now suppose I have a class ...

Is anybody using the named boolean operators?

Or are we all sticking to our taught "&&, ||, !" way? Any thoughts in why we should use one or the other? I'm just wondering because several answers state thate code should be as natural as possible, but I haven't seen a lot of code with "and, or, not" while this is more natural. ...

php string versus boolean speed test

I'm looking at trying to optimise a particular function in a php app and foolishly assumed that a boolean lookup in a 'if' statement would be quicker than a string compare. But to check it I put together a short test (see below). To my surprise, the string lookup was quicker. Is there anything wrong with my test (I'm wired on too much c...

Why does !1 give me nothing in Perl?

This is strange. The following: $sum = !0; print $sum; prints out 1 as you would expect. But this $sum = !1; print $sum; prints out nothing. Why? ...

java assert gives strange results

what should the following java code do? public class foo{ public static void main(String[] args){ boolean mybool=false; assert (mybool==true); } } Should this throw an assertion error? and if not why not? (I'm not getting any errors!) ...

Xml Serialization vs. "True" and "False"

I'm having an issue with deserializing an XML file with boolean values. The source XML files I'm deserializing were created from a VB6 app, where all boolean values are capitalized ("True", "False"). When I try to deserialize the XML, I'm getting a System.FormatException: The string 'False' is not a valid Boolean value. Is there a w...

Datagridview on RowLeave not assigning proper values to booleans

I have a DataViewGrid I populated from a DataTable in a query to a DB. While trying to capture the Row_Leave event, so I could properly update it, I can't seem to capture the latest value in boolean columns. If I update just a text field, when I access the underlying DataSource I get the latest value I entered, buy if I access the boole...

C# newbie: what's the difference between "bool" and "bool?" ?

Hello, I'm starting with C#, and encountered something that puzzles me. I use the "bool" type for variables as I was used to in C++, and I try to put the values of functions or properties I expect to be boolean into my variable. However often I encounter cases where the result type is "bool?" and not "bool" and the implicit casting fail...

Best way to use my singleton

I started to develop my singleton class but I have a problem. What I want to do is have a search objects containing the values of the search form that I could use in several views. I want to have the ability to get the singleton in any view in order to perform the search or build the search form. So I have a set of values with a boolean ...

How can you have boolean -datatype in VP-uml?

My ERD is I use at the moment integer(2) to signal that the datatype is boolean because the program does not allow me to type boolean to the datatype -field. How can you have boolean as a datatype in the program VP-uml? [edit] The problem still persists. I see the following in my VP-uml: ...