boolean

Positive or negative boolean field names

A table's boolean fields can be named using the positive vs the negative... for example, calling a field: "ACTIVE" , 1=on / 0=off or "INACTIVE" , 0=on / 1=off Question: Is there a proper way to make this type of table design decision, or is it arbitrary? My specific example is a messages table with a bool field (private/public)...

Store an array or hash of booleans in Ruby and Rails

I want to create a set of values in Ruby which I can store and retrieve in a MySQL databse under Rails. In Delphi I would use: //Create an enumeration with four possible values type TColour = (clRed, clBue, clBlack, clWhite); //Create a set which can hold values from the above enumeration TColours = set of TColours; //Create a var...

Evaluation of boolean expressions in Python

What truth value do objects evaluate to in Python? Related Questions Boolean Value of Objects in Python: Discussion about overriding the way it is evaluated ...

What is the standard approach for implementing a one-time Boolean switch?

Let's say I have some code like the following, and that processData gets executed hundreds or even thousands of times per minute: class DataProcessor { private: DataValidator* validator; bool atLeastOneDataPoint; bool dataIsValid(Data* dataToValidate) { return validator->validate(dataToValidate); } public: /...

Return False if variable isn't boolean

How can I the code below to return False if usable is anything other than True (anything other than bool), currently my code throws an exception usable is not a bool. if (!Boolean.Parse(readValue("Useable"))) return true; return (defined.ContainsKey(key) || (key == "Useable")); ...

uninterlace bits from 16 bit value

I have a 16 bit value with its bits "interlaced". I want to get an array of 8 items (values 0 to 3) that stores the bits in this order: item 0: bits 7 and 15 item 1: bits 6 and 14 item 2: bits 5 and 13 ... item 7: bits 0 and 8 This is a trivial solution: function uninterlace(n) { return [((n>>7)&1)|((n>>14)&2), // bits 7 and 15 ...

Core Data mishandles NSCFBoolean ?

Hi, I've got a Core Data managed object that has an attribute with a "Boolean" type. In my header file I've got this: @property (nonatomic, retain) NSNumber * includeInHistory; and I'm using a @dynamic includeInHistory implementation When interacting with an instance of this managed object before saving to disk, I've got something th...

Casting a boolean array in Java?

Is there anything I can cast a boolean array to in Java? It would be nice if I could say boolean[] bools = new boolean[8]; int j = (int)bools; But I'm not sure if that's feasible in Java. ...

Return DataTable based on boolean param

Hi All, I have a table that has a field, "IsActive," that indicates whether a record has been "deleted" or not. Currently, I retrieve this info like so: public DataTable GetContractors(bool IsActive) { SqlParameter paramIsActive = new SqlParameter("@IsActive", SqlDbType.Bit); paramIsActive.Value = IsActive; ...

Bash Can not get IF to work like I want to

I need to understand bash if expressions. Sure, I've used Google. I know that it goes something like this: if [ expr operator expr ] then doSomeThing fi However, I understand that Bash doesn't have a boolean data type. I want to check if the file passed as an argument ($1) exists. The way I would do this straight of my mind: if [ -...

Suppressing Booleans on Crystal Reports

Simple question, yet i haven't found the answer. Anybody here know how to suppress a boolean field from displaying a "False" ? For example in my report, I have fields that say True or False...i'd rather just see a True and have crystal reports suppress the "False" Anybody know how to do that? ...

Python things which are neither True nor False

I just found this : a = (None,) print (a is True) print (a is False) print (a == True) print (a == False) print (a == None) print (a is None) if a : print "hello" if not a : print "goodbye" which produces : False False False False False False hello So a neither is, nor equals True nor False, but acts as True in an if statement. W...

Why/When to use (!!p) instead of (p != NULL)

In the following code, what is the benefit of using (!!p) instead of (p != NULL)? AClass *p = getInstanceOfAClass(); if( !!p ) // do something else // do something without having valid pointer ...

Why must I assign the result of PHP's end() array function to a variable to operate on the result?

I've tried to delete the possibly empty last entry of an array as follows but I get the error: "Can't use function return value in write context": if (empty(end($crontabEntryList))) { array_pop($crontabEntryList); } If I first assign end's return value to a variable (as at the bottom) I am able to delete that last entry if emp...

JSF boolean output

Hi, Is there a way in JSF to output some text based on a boolean? For example: h:outputText value="Black" rendered="#{bean.isBlack}" The bean property is called isBlack not getIsBlack...I dont want to rename this. Thanks, D ...

PLT Scheme noob: Boolean and/or aren't procedures?

I'm trying to make a truth-table generator for a digital electronics course because that's how I have fun in my spare time and don't judge me. Anywho, I figured I'd have a hash with the string equivalent of operators as keys, and the Scheme procedures that correspond to those operators as values. E.g. (define operator-table #hash(("...

Two member enumeration vs. boolean value

This question has in the back of my mind for some time, sorry if it appears subjective. There are some disadvantages in using bool in public properties and constructors for data objects. Consider the following code as an example. Using bool: public class Room { public string Name { get; set; } public bool Bookable { get; set; }...

Boolean Concatenation? What's the real term for this pattern?

Please consider the following function body: var isValidated = true; $(selector1).each(function(){ //do validation with local f()... isValidated = f() && isValidated; }); $(selector2).each(function(){ //do validation with local f()... isValidated = f() && isValidated; }); $(selector3).each(function(){ //do validati...

can php return a boolean? => return $aantal == 0;

hi very short question can php return a boolean like this: return $aantal == 0; like in java you can public boolean test(int i) { return i==0; } or do you Have to use a if contruction? because if i do this. $foutLoos = checkFoutloos($aantal); function checkFoutloos($aantal) { return $aantal == 0; } echo "foutLoos = $foutLoo...

MutableArray loaded with a .plist file Boolean Value. How do I test whether True or False??

I seem to have a problem understanding how to conditionally test a boolean value loaded from a .plist to a mutablearray. I simply dont understand what i am supposed to do and continue to receive an error: Passing argument 1 of 'numberWithBool:" makes integer from pointer without a cast. any help understanding this is appreciated! he...