532 questions
5
votes
2
answers
179
views
How does the `(…) and (…) or (…)` idiom mimic a ternary operator in Lua?
This statement mimics a ternary operator in the Lua programing language:
local result = condition and true_value or false_value
But how does it work? Why does it give true_value if the condition is ...
1
vote
2
answers
103
views
truthy values == false return true
So I am a beginner at javascript and learnt that there are only a limited falsy values: false, 0, -0, BigInt 0n, “”, null, undefined, NaN
Yet when I use the == operator with truthy values, this ...
0
votes
0
answers
85
views
Using 2x4 active decoder and a NOR gate design a XOR gate
I am trying to create a a XOR gate. only from 2x4 and NOR Gates. however I am stuck. Please draw the diagram or give image of this.
0
votes
4
answers
225
views
Does the && (logical AND) operator have a higher precedence than || (logical OR) operator in Java?
From my previous knowledge the (logical AND) has a higher precedence than the (logical OR), so for example in the following line of Java code boolExp2 will be compared with boolExp3 before comparing ...
0
votes
1
answer
62
views
Octave: Boolean AND returns wrong number
I am trying for several hours to calculate a boolean AND operation in Octave.
It return a wrong number.
I want to calculate following numbers:
result = 4037 & 63
result should be 5 but i get 1.
I ...
0
votes
0
answers
74
views
Why is my Boolean operation in VS Code not given expected result? [duplicate]
I tried to solve C++ expression quizzes on TLX. There is a problem about Boolean operation which I got confused. The question is like "If a = true, b = false, c = true, and d = true, then the ...
0
votes
1
answer
51
views
Why is the first "if" activated by itself when the second "else if" condition is met?
Basically, when the condition "event.target === checkbox && active" is met, the value of 'active' becomes "false". Therefore, the next click on the checkbox will satisfy ...
1
vote
2
answers
114
views
How do I get this code to accommodate any given number by only using boolean logic (no conditionals/ functions)
Here is the problem:
number = 1101
#You may modify the lines of code above, but don't move them!
#When you Submit your code, we'll change these lines to
#assign different values to the variables.
#
#...
-2
votes
1
answer
122
views
How is boolean xx = (43.3L == 3.333f) syntactically correct
I'm have a problem with understanding this question about syntax it says the answer is
boolean xx = (43.3L == 3.333f);
but i don't understand how it is
Which of the following Java statements are NOT ...
2
votes
2
answers
162
views
Why do I get this error? invalid operands to binary expression [duplicate]
I want to check if 2 struct pointers point to the same values, but I get this error:
./07ex.c:158:15: error: invalid operands to binary expression ('RGB' (aka 'struct RGB_') and 'RGB')
return *x == *y;...
0
votes
1
answer
96
views
Bool in C# works something unclear for me
Here goes an example of C# code. I did not get why in first case we will have 1 instead of 0.
Why does it return 1 instead?
static void Main(string[] args)
{
int firstNumber = 0;
bool ...
0
votes
0
answers
74
views
Using bool type conversion operator and Comparison operator overload methods in the same file
I'm trying to do a code, but every time I ran it, it uses the wrong operator:
class Date {
private:
int m_year;
int m_mon;
int m_day;
int m_ErrorCode;
int m_CUR_YEAR;
...
-2
votes
1
answer
73
views
Boolean always convert to zero in Android
I'm using Android Studio Chipmunk 2021.2.1 Patch 1
Android Studio Chipmunk | 2021.2.1 Patch 1
Target SDK 31, Min SDK 23
I'm importing data from a web service that looks like this:
I added the last ...
-1
votes
2
answers
192
views
How do I identify the Boolean Expression of this logic circuit?
As the title says, what can be the possible boolean expression of the logic circuit given? The Truth table is also included.Logic Circuit
I have tried to solve my own Boolean Expression and coded it ...
1
vote
2
answers
272
views
Why does AND and OR infix functions from kotlin-stdlib don't short-circuit as && and ||?
I've noticed that both and and or kotlin-stdlib's infix functions have this javadoc:
Performs a logical `and` operation between this Boolean and the [other] one. Unlike the `&&` operator, this ...