456 Answered Questions for the topic logic
Logic Boolean
07/13/19
How do I determine if *exactly* one boolean is true, without type conversion?
Given an arbitrary list of booleans, what is the most elegant way of determining that *exactly* one of them is true?
The most obvious hack is type conversion: converting them to `0` for `false`...
more
07/13/19
Does the ``??`` operator use shortcircuiting?
Does the `??` operator in C# use shortcircuiting when evaluating?
var result = myObject ?? ExpressionWithSideEffects();
When ``myObject`` is non-null, the result of...
more
07/13/19
Most succinct way to determine if a variable equals a value from a 'list' of values?
If I have a variable in C# that needs to be checked to determine if it is equal to one of a set of variables, what is the best way to do this?
I'm not looking for a solution that stores the set in...
more
07/11/19
What is fuzzy logic?
I'm working with a couple of AI algorithms at school and I find people use the words Fuzzy Logic to explain any situation that they can solve with a couple of cases. When I go back to the books I...
more
Logic
07/11/19
Math logic question
Natalie has $68. If she doubles the number of her $5, she will have $103. How many $5 bills does Natalie have originally?
07/11/19
How to calculate scores?
This question is more related to logic than any programming language. If the question is not apt for the forum please do let me know and I will delete this.
I have to write a logic to calculate...
more
Logic Xor
07/11/19
Pass two integers as one integer?
I have two integers that I need to pass through one integer and then get the values of two integers back.
I am thinking of using Logic Operators (AND, OR, XOR, etc) .
Logic
07/09/19
Jane can play the piano but not the flute while Jeremy plays the violin and the flute .Shelly plays the violin but not the piano and Josephine plays the flute but not the violin. If each child
Jane can play the piano but not the flute while Jeremy plays the violin and the flute .Shelly plays the violin but not the piano and Josephine plays the flute but not the violin. If each child...
more
UInt64 and "The operation overflows at compile time in checked mode" - CS0220?
This feels like a stupid question, but I can't seem to see the answer. I have an UInt64, which is supposed to have a max value of
UInt64.MaxValue 18446744073709551615
However, when I try to...
more
Split down a number in seconds to days, hours, minutes, and seconds?
I've heard that it's possible to accomplish this using the modulus `%` operator present in most programming languages. The real question is, how? I'm unfamiliar with how modulus works, so I've had...
more
Logic Truth Table
07/07/19
Write the following compound statement in symbolic form. This is not an apple an apple if it's not a fruit fruit.
Let p and q represent the following simple statements.p: This is an applean apple.q: This is a fruitfruit.
07/06/19
XOR of three values?
What is the simplest way to do a three-way exclusive OR?
In other words, I have three values, and I want a statement that evaluates to true IFF only *one* of the three values is true.
So far,...
more
07/05/19
C# logic order and compiler behavior?
In C#, (and feel free to answer for other languages), what order does the runtime evaluate a logic statement?
Example:
DataTable myDt = new DataTable();
if (myDt != null &&...
more
07/05/19
VBA If <any of these> = <value>?
I'm fairly new to VBA, and I can't find an easy way to test if any of the specified variables equal a specified value. The below seems to work, but is there an easier way to do it?
If variable1 =...
more
07/04/19
What' s the difference between <= and := in VHDL?
Currently, I am learning some FPGA design techniques using VHDL, my problem is whether we can use := and <= interchangeably in VHDL or not, though I've seen the use of := in constants...
more
Force all && to be executed?
Consider the following variadic function
template <typename Type, typename... Types>
bool f(Type& arg, Types&... args)
{
return f(arg) && f(args...);
}
template...
more
determine whether point lies inside triangle?
The program needs to read the values of three coordinates
- P1(x1,y1)
- P2(x2,y2)
- P3(x3,y3)
as well as another coordinate P(x,y) and determine whether this point is inside a triangle...
more
06/28/19
Logical fallacy detection and/or identification with natural-language-processing?
Is there a package or methodology in existence for the detection of flawed logical arguments in text?
I was hoping for something that would work for text that is not written in an academic...
more
Logic Algorithm
06/27/19
What's the approach to solving this kind of logic problem?
What would be the approach to a kind of problem that sounds like this:
A says B lies
B says C lies
D says B lies
C says B lies
E says A and D lie
How many lie and how many tell the truth?
I...
more
06/27/19
What is the Objective-C way of getting a nullable bool?
How should I go about getting a bool value that I can assign true, false and nil to in Objective-C? What is the Objective-C way of doing this? Much like C#'s Nullable<bool>.
I'm looking to...
more
06/27/19
P implies Q, how to read in english?
how to read P implies Q in classical logic?
example :
Distributivity:
Ka(X->Y) -> (KaX -> KaY)
This is modal logic which uses classical logic rules.
KaX : a knows the that X is...
more
Logic C#
06/27/19
C# convert a string for use in a logical condition?
Is it possible to convert a string to an operator for use in a logical condition.
For example
if(x Convert.ToOperator(">") y) {}
or
if(x ">" as Operator y){}
I appreciate that this...
more
06/27/19
Determine the sign of a 32 bit int?
Using ONLY:
! ~ & ^ | + << >>
NO LOOPS
I need to determine the sign of a 32 bit integer and I need to return 1 if positive, 0 if 0 and -1 if negative.
Any ideas? I first...
more
Digit-increasing number test?
A number is called digit-increasing if it is equal n + nn + nnn + ... for some digit n between 1 and 9. For example 24 is digit-increasing because it equals 2 + 22 (here n = 2).
Actually, a friend...
more
Still looking for help? Get the right answer, fast.
Ask a question for free
Get a free answer to a quick problem.
Most questions answered within 4 hours.
OR
Find an Online Tutor Now
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.