boolean Questions
8
Solved
In my program, I have a statement like the following, inside a loop.
y = (x >= 1)? 0:1;
However, I want to avoid using any relational operator, because I want to use SIMD instructions, and am...
Inez asked 29/4, 2017 at 9:0
5
Solved
Is it possible to differentiate between false and an unset boolean value in go?
For instance, if I had this code
type Test struct {
Set bool
Unset bool
}
test := Test{ Set: false }
Is there...
7
Solved
In Java 8, I have a variable, holding an optional boolean.
I want an action to be executed, if the optional is not empty, and the contained boolean is true.
I am dreaming about something like ifP...
Repatriate asked 16/10, 2017 at 8:55
12
Solved
I was asked to filter out NaN, null, 0, false in an array.
Luckily I have answered the question.
function bouncer(arr) {
function filterer(arr) {
return arr > 0|| isNaN(arr) === true;
}
a...
Landlordism asked 10/8, 2015 at 17:7
5
Solved
Is there a concise way to loop over true/false in C#?
I have ~20 lines of code in a unit test I'd rather not duplicate to toggle one boolean true/false.
I could break it off into a function and c...
7
Solved
Is there a utility method in Java which converts Boolean into boolean and automatically handles null reference to Boolean as false?
Edrick asked 25/7, 2014 at 7:37
2
Solved
As it said in JVMS8:
Although the Java Virtual Machine defines a boolean type, it only provides
very limited support for it. There are no Java Virtual Machine instructions solely
dedicated to oper...
7
Solved
During a recent job interview process, I submitted some sample Perl code which used the so-called "secret" !! operator. Later, when discussing the code, one of the interviewers asked me why I chose...
Eserine asked 8/10, 2015 at 11:9
5
Solved
I want to return the value of my array plus the return value of the recursive call.
However, for some reason, Java does not want to have the method name after the constructor.
In addition, when I t...
5
I just stumbled across this and I couldn't find a sufficient answer:
x = ""
Why then is:
x == True
False
x == False
False
x != True
True
x != False
True
Am I supposed to conclude that x is...
3
Solved
I am new to C++ and I was wondering how the function cin in case of a boolean data works.
Let's say for instance :
bool a;
cin >> a;
I understand that if I give 0 or 1, my data a will be eit...
2
I have a numpy array containing 10^8 floats and want to count how many of them are >= a given threshold. Speed is crucial because the operation has to be done on large numbers of such arrays. The c...
Epiphytotic asked 26/1, 2014 at 18:41
2
Solved
I have some auto-generated enums that I need to map to boolean values in a MapStruct mapper. They go like this:
enum YN {
Y("Y"), N("N")
}
enum ZO {
_0("0"), _1("1")
}
I've tried to use @Valu...
8
Solved
I was wondering if it was possible to do a ternary operation but without returning anything.
If it's not possible in Java is it possible in other languages, if so which ones apply?
name.isChecked...
2
Solved
If I try to create a new column in an R dataframe by adding 3 boolean expressions in one step, it results in a boolean rather than an integer. If I use an intermediate step to first create columns ...
7
Solved
I'm trying to convert an argument of my PowerShell script to a boolean value. This line
[System.Convert]::ToBoolean($a)
works fine as long as I use valid values such as "true" or "false", but wh...
Henpeck asked 15/12, 2014 at 13:0
4
Solved
This program is in response to the assignment:
"Create a method named Sum() that accepts any number of integer parameters and
displays their sum. Write a Main() method that demonstrates that the ...
5
Solved
I am working on a trading API (activex from interactive brokers)which has a method called:
void reqMktDataEx(int tickerId, IContract contract, string generalDetails, int snapshot)
The issue is aro...
1
Solved
While making use of a Range to solve a problem I noticed that a Range with 0 elems would be True as a Bool. In what scenarios could a Range be False?
[0] > (^0).so
True
[1] > (1..0).so
True
...
6
As we have %d for int. What is the format specifier for boolean values?
10
Solved
I was converting from Swift 2 to Swift 3. I noticed that I cannot convert a boolean value to integer value in Swift 3.
let p1 = ("a" == "a") //true
print(true) //"true\n&q...
10
Solved
Is there a better way to negate a boolean in Java than a simple if-else?
if (theBoolean) {
theBoolean = false;
} else {
theBoolean = true;
}
8
Solved
In Swift 2.x I believe I could do:
let number = 1
let result = Bool(number)
print(result) // prints out: true
But since Swift 3 I've been unable to do this and it gives me the error:
Cannot ...
3
Solved
Why are bools sometimes referred to as "flags"? Is it just a metaphor or is there some historical reason behind it?
28
Solved
I would like to use argparse to parse boolean command-line arguments written as "--foo True" or "--foo False". For example:
my_program --my_boolean_flag False
However, the following test code do...
Bike asked 21/2, 2013 at 17:37
1 Next >
© 2022 - 2024 — McMap. All rights reserved.