boolean

Speed of boolean expression (C#)

Hello I was thinking of what is better to write (in matter of speed and/or efficiency): bool Method(...) { ... } ... bool result = Method(...); if (result == false) { ... } // or if (!result) { ... } (or variation with true and if(result)) I'm asking because I use first one (result == false) but sometimes it gets very long, espec...

boolean true -- positive 1 or negative 1?

I'm designing a language, and trying to decide whether true should be 0x01 or 0xff. Obviously all non-zero values will be converted to true, but I'm trying to decide on the exact internal representation. What are the pros and cons for each choice? ...

BOOL to NSString

If I have a method that returns a BOOL, how do I cast that to a NSString so I can print it out with an NSLog? For example,I tried doing this, which isn't working: NSLog(@"Is Kind of NSString:", ([thing isKindOfClass:[NSString class]]) ? @"YES" : @"NO"); But I really want to actually turn the return value into a NSString... I know ...

Boolean types

During code review I discovered many places of our C# code that looks like this: if(IsValid()) { return true; } else { return false; } or even "better": return (IsValid()? true : false); I always wondered why not just write the code like this: return IsValid(); This is the way I would write this code. I ain't questioni...

boolean algebra article/book

i got really confused every time when i encounterd bit operations,especially those shifts,rotates,overflow things etc.I wonder if there's any book/article on the web introducing boolean algebra,which could give me a solid background of boolean algebra,thanks! ...

Online Puzzles and games for learning boolean algebra

I'm looking for some online game, where it tests our ability in boolean algebra. My cousin is young and has just learnt using logic gates. Is there any thing interesting available out there for him to practice online? ...

IEEE floating point representation issue

Suppose a hypothetical 6-bit floating point representation, with the fraction occupying 2 bits, and the exponent occupying 3 bits. What is the biggest (except for ) number this 6-bit floating point representation can support? I read this from the book "Computer System: A programmer's perspective" on page P71. I guess this to be 28, but ...

Complex SQL where clause: whether to factor logic

I've got a complex SQL where clause that just got more complex because of a requirements change. There are four basic sets of cases, each with a different combination of other factors. It's more readable (in my opinion) to have the four cases as separate branches of the where clause, and to repeat the redundant criteria in each branch. B...

True until disproven or false until proven?

Hello, I've noticed something about my coding that is slightly undefined. Say we have a two dimension array, a matrix or a table and we are looking through it to check if a property is true for every row or nested dimension. Say I have a boolean flag that is to be used to check if a property is true or false. My options are to: Initi...

Valid java bean names for booleans

I know most variable names will work with "is", such as isBlue, but is "has" also a valid prefix, like hasProperty? ...

booleans in rails with sqlite

I am a bit of a noob still with rails, but I am running across something that seems a bit odd. I added a boolean field to a model in the database thusly t.column :admin, :bool, :default => false, :null => false However, the value in the sqlite3 database seems to be either 't' or 'f'. That is fine, but I would still expect user.admin? ...

SSIS Derived Column Expression for Boolean-to-Char CAST

Hello, I am having a bit of a struggle with Expressions inside SSIS Derived Columns. My source field is a BOOLEAN data type. It's destination field is a SQL CHAR datatype. ** Note that I did not design either of the schemas. If I had my way, the data types would match up. Unfortunately, this is not my case! I found a great example of...

what is the purpose of javascript new Boolean() ?

what is the use of var flag = new Boolean(false); in compare to var flag = false; when would you actually use new Boolean? ...

strange boolean expression solving in php

$foo = 0; if($foo == 'on') $foo = 1; echo $foo; It should be expected the above code outputs "0". However it doesn't, somehow $foo == 'on' results in TRUE, although this obviously is wrong. Replacing the expression with $foo === 'on' gives the right answer, so any suspicions this might be some typing issue seem to be confirmed. Neve...

cfgrid boolean column as Yes/No

I have a boolean type column in an html cfgrid. The data is stored in the database as 1/0 and is returned from CF as such. I want the user to see Yes/No instead of 1/0. I tried QuerySetCell, and couldn't get it to work. The form is editable, when you double click the cell, the checkboxes show and it updates as it should. The only ...

How to best convert VARIANT_BOOL to C++ bool?

When using COM boolean values are to be passed as VARIANT_BOOL which is declared in wtypes.h as short. There are also predefined values for true and false: #define VARIANT_TRUE ((VARIANT_BOOL)-1) #define VARIANT_FALSE ((VARIANT_BOOL)0) Which is the best way to convert from VARIANT_BOOL to C++ bool type? Obvious variants are: compare...

passing boolean parameters to named routes in rails

I want to explicitly pass a boolean false to params[:closed] and I've got something like this: = link_to 'appointments', appointments_path(:closed => false) But this is not working as rails is treating a false boolean as I don't want anything set for this params, is there any way to get around this? update: the false I'm passing in i...

Sort Objects by Boolean values in Ruby

My apologies if this has been answered before or is obvious...did some searching here and on the Goog and couldn't find an answer. I'm looking to sort an array of Providers by price and whether they are a preferred_provider? (true or false) For instance in array p of Providers... p1.price == 1, p1.preferred_provider? == false p2.price...

What is NOR logical operator?

Is nor: !(a or b) !a or !b !(a and b) something else? ...

How can I fix an int-to-bool warning in C++?

I get a warning in MSVC++ when I try to read an integer from a file and make a bool variable equal it. accessLV[i] = FileRead(file1, i + 1); (accessLV is an array of bools, FileRead is a function I made to decrease the syntax involved in reading from a file, i is because the statement is within a for loop) I've tried using a static_c...