boolean

Enumeration relying on integer boolean conversion

In my compiler project, I have an enumeration that goes like enum Result { No, Maybe, Yes }; I have put No explicitly at the first position, so that i can rely on the boolean evaluation to false. If my compiler is not sure about something, and has to wait for facts until runtime, its analysis functions will return Maybe. Used li...

How can I create a large boolean search string from a list of keywords?

Hi, first time here, so please treat me like a fool who knows nothing about anything. I have a very specific problem that i'm trying to find an answer to, and i'm hoping you might find this quite easy... I'm working on a project where we need to create very long boolean queries from lists of keywords (up to 500), and i'm looking for a s...

Boolean operators which return one of the operands

In Python, and maybe in Javascript, the boolean or and and operators return one of the operands, instead of true or false. In Python, one of the operands is returned: '' || 'hello' == 'hello' In comparison, in PHP: '' || 'hello' == true; Now, How is this behavior of boolean operators called? Does this also work in Javascript in all...

Return boolean value through multiple functions

I have some Javascript code that needs to end with either a true or false value being returned. However, when the true/false value is computed, the original value has passed through multiple functions, like so: var txt = 'foo' function one(txt) { if(txt == 'foo') { two(txt); } } function two(txt) { if(txt == 'foo') { three(txt); } }...

Strange logic with bool

Hello, I can't understand one thing with logic in python. Here is the code: maxCounter = 1500 localCounter = 0 while True: print str(localCounter) + ' >= ' + str(maxCounter) print localCounter >= maxCounter if localCounter >= maxCounter: break localCounter += 30 And the result output: ... 1440 >= 1500 False 1470 ...

Ruby: Forcing an Integer (Fixnum/Bignum) over Boolean

I have an integer that is initially 0 and, after calculations, often ends up between 0 - 99. The problem is that since early on in the game, it calculates out to 0 or 1 often, it gets assigned as a TrueClass or FalseClass instead of a numerical value, which messes up a future x > 0 comparison. Is there a built-in Ruby way to force the va...

sql boolean datatype alternatives

What are the situations when you would use a foreign key to a separate table rather than use a boolean (i.e. BIT in SQL Server) For example would you replace the following two booleans in this table: engine_sensors -------------- id (int, primary key) name (varchar(50)) fault_code (int) display_warning (boolean) /* if fault show driver...

objective c arrays of floats and booleans possible?

NSArray chemConstantArray = [[NSArray alloc] initWithObjects:0.0021400, 0.0012840, 0.0010700, nil]; Gives me four errors: Incompatible type for argument 1 of 'initWithObjects:' Invalid initializer Statically allocated instance of Objective-C class 'NSArray' x 2 Which makes sense, as floats are not objects, but how can I make an arr...

XSLT boolean value

I tried searching for my issue on here and was unsuccessful. <xsl:for-each select="$all_events[g:active = 1]"> <xsl:sort select="g:event_date" order="descending"/> <xsl:variable name="fileName"><xsl:value-of select="fn:replaceAll(string(@alf:file_name), '.xml', '.html')"/></xsl:variable> <xsl:variable name="fileU...

C# 2.0 double handling - Bizarre behaviour

Double dblValue = 0.0001; Boolean a = (dblValue >= (1 / 1000)); Boolean b = (dblValue >= 0.001); Console.WriteLine("dblValue >= (1 / 1000) is " + a); Console.WriteLine("dblValue >= 0.001 is " + b); Console.ReadLine(); The above C# code evaluates 'a' to true and 'b' to false. In VB.NET, the equivalent code evaluates 'a' to false and 'b'...

AND Gate with delayed inputs in C#

I am trying to implement a boolean AND gate with multiple inputs. Each input has an integer identifying it. Input signals arrive randomly, and are stored at the gate (so it's not a pure AND gate, but one with delayed inputs). Only when all the input signals have arrived, does the gate fire. Note: 2 signals arriving at the same input do n...

c++ convert class to boolean

With all of the fundamental types of C++, one can simply query: if(varname) and the type is converted to a boolean for evaluation. Is there any way to replicate this functionality in a user-defined class? One of my classes is identified by an integer, although it has a number of other members, and I'd like to be able to check if the i...

Convert char Array/string to bool Array

Hi, We have this field in our database indicating a true/false flag for each day of the week that looks like this : '1111110' I need to convert this value to an array of booleans. For that I have written the following code : char[] freqs = weekdayFrequency.ToCharArray(); bool[] weekdaysEnabled = new bool[]{ Convert.ToBoolean(int....

WPF Radiobutton (two) (binding to boolean value)

Hi ! I have a property of type boolean presented with checkbox. I want to change that to two radiobuttons that bind on the same property presenting the value true/false. How can i do that ? thanx ...

Flipping a boolean value with a simple view in Django?

I have a simple view, but can't get it to do what it's supposed to, which is simply flip a Boolean Value: def change_status(request): request.user.get_profile().active=not request.user.get_profile().active return render_to_response('holdstatus.html', { 'user' : request.user, }) In addition to "not", I've tried '-' and '!', but al...

Switch Off iPhone Screen

Hi there, I am looking for a way to turn off the iPhone screen without the iPhone going to sleep. I don't really mind if turning the screen off is against apple rules. Would setting window alpha to 0 do the trick? Is there maybe some sort of boolean value I can change? If anyone has an ideas they would be much appreciated. Many thanks...

How to determine if two boolean expressions are the same

I need to determine if two different boolean expressions are the same. For example example, S1 = a b, S2 = (a b) b; these two are in fact the same. So I need to detect if they are the same. I am using C#. ...

'true' in Get variables

In PHP, when you have something in the URL like "var=true" in the URL, does the 'true' and 'false' in the URL get translated to boolean variables, or do they equal the text 'true' or 'false'? For instance, would, with the url having "var=false" in it: if ($_GET['var'] == false) { ... } work? Or would the variable always be true since ...

jQuery Plugin On Event Return True/False

I'm creating a plugin that replaces alerts/confirms for a project and I was curious if there was a way to make it like a real confirm where you can do: if(confirm('Yes or no?')){alert('You agreed!');} Right now I could do with a call back using this syntax: $.alert('yes or no',{type:'confirm'}); But i want to be able to do: if($.a...

Boolean value not being passed with jQuery/ $.get - Why?

I have my front end script which has the following jQuery code: $.get("/backend/post.php", { title: title, message: post, stick: sticky }, function (output) { alert("Call Back"); } }, "json"); stick is a boolean value, the other two are strings. I've confirm...