Hello,
I have a piece of code that gives a runtime error. Can anyone help find out why?
vector<int> intData;
vector<bool> boolData;
for(int i=0;i<19000;i++)
boolData.push_back(false);
string ofile = "tree.dat";
ofstream fout(ofile.c_str(),ios::out | ios::binary);
if (!boolData.empty()) fout.write((char *)&boolData[0], size...
Is it possible to use ActiveRecord named_scopes to create one query with sql OR clauses?
When I use
Model.scope1.scope2
generated query is conjunction of these scopes.
...
I haven't done much c programming but when I do when I need a false I put 0 when I want true I put 1, (ex. while(1)), in other cases I use things like "while(ptr)" or "if(x)".
Should I try using C99 booleans, should I recommend them to others if I'm helping people new to programming learn c basics(thinking of cs 1?? students)?
I'm p...
There is a known bug in JAXB: https://jaxb.dev.java.net/issues/show_bug.cgi?id=733
JAXB does not properly generate boolean field getters and setters, this bug is left unfixed for backwards compatibility.
A JAXB plugin exists and will ensure that the following getters and setters for boolean fields are generated:
setXXX(Boolean value...
I have a piece of code which is said to return a bool value. I am a new programmer, so could someone give me code that will determine if the file at the path exists?
NSString *docsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *path = [docsDirectory stringByAppen...
I have a boolean field called "saved" in my database. I want to toggle this field by clicking on a text link that changes from "Save" to "Unsave" depending on the situation, and updates my "Customer" table with 0 or 1. I imagine Javascript may be a way to go for this but I am not experienced enough (yet!) in Javascript to know how to cod...
I've just seen this line of code in my housemates code.
Bool bool = method() > 0;
or
string name = "Tony";
boolean nameIsTony = name == "Tony";
This would result in nameIsTony becoming true.
So you can have an inline conditional statement?
What is this called?
...
What does 'Conditional expressions can be only boolean, not integral.' mean? I do not know Java and I know C++ deffenetly not enought to understend what it means.. Please help (found in http://www.javacoffeebreak.com/articles/thinkinginjava/comparingc++andjava.html in Comparing C++ and Java item 7 sub item 1)
...
I was looking to create a boolean test for a number when it is 10, 20, 30, 40. This would be used in a loop, 1 to 100. ParseInt seems a bit part but was wondering what a method for a true or false answer maybe.
...
I've found boolean mode of MySQL full text search useful, however there are a couple of things I can't seem to figure out how to achieve.
For instance imagine I have a full text column containing the words "Steve's Javascript Tutorial - Part One".
I would like to match this for each of the following searches: "tutorials", "javascript t...
Hi,
Is there a short way to toggle a boolean?
With integers we can do operations like this:
int i = 4;
i *= 4; // equals 16
/* Which is equivalent to */
i = i * 4;
So is there also something for booleans (like the *= operator for ints)?
In C++:
bool booleanWithAVeryLongName = true;
booleanWithAVeryLongName = !booleanWithAVeryLongN...
An interviewer recently asked me this question: given 3 boolean variables a, b, c, return true if at least 2 out of the 3 are true.
My solution follows:
boolean atLeastTwo(boolean a, boolean b, boolean c) {
if ((a && b) || (b && c) || (a && c)) {
return true;
} else {
return false;
}
}
He said that this can be improved ...
Hello to all.
First: I'm running postgresql 8.2 and testing my queries on pgAdmin.
I have a table with some fields, say:
mytable(
id integer,
mycheck boolean,
someText varchar(200));
Now, I want a query similary to this:
select id,
case when mycheck then (select name from tableA)
else (select name from tableB) end ...
I'm working on an application in vb6 that draws information from a database. I've come across many problems that come from null values in the database as vb6 functions and subroutines don't like nulls. The string problem is easily solved by concatenating an empty string to the value. But what do I do for a null value where a boolean shou...
Is there Boolean data in sql server like mysql?
What is the alternative in sqlserver
...
In the web app I am currently developing I have a form, and one of the fields is a boolean "IsFixedCost" (true/false).
The natural way, to me, to represent it on the form is with a checkbox: FixedCost? (checked = true, unchecked = false).
My boss forced me to change it in a combobox: FixedCost? -> option1: Fixed, option2: Variable
bec...
so.. is this possible? because I see some native php functions can do that
for example strpos() can return 0 which can apparently be true
...
In my case, every "item" either has a property , or not. The properties can be some hundreds, so I will need , say, max 1000 true/false bits per item.
Is there a way to store those bits in one field of the item ?
...
False is equivalent to 0 and True is equivalent 1 so it's possible to do something like this:
def bool_to_str(value):
"""value should be a bool"""
return ['No', 'Yes'][value]
bool_to_str(True)
Notice how value is bool but is used as an int.
Is this this kind of use Pythonic or should it be avoided?
...
Sorry if this is a "Logical Operators 101" kind of question. I've been staring at my screen for 15 minutes trying to wrap my head around it, but I'm stuck.
Is there a more concise/elegant way to phrase the following (this is JavaScript syntax, but it's not a language-dependent question):
if (!something && !something_else) {
// do som...