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 an array. I'm more curious to see if there is a solution that uses boolean logic in some way to get the answer.
I know I could do something ...
Is there ever a circumstance in which I would not want to use the AndAlso operator rather than the And operator? or in which I would not want to use the OrElse operator rather than the Or operator?
...
I'm someone who writes code just for fun and hasn't really delved into it in either an academic or professional setting, so stuff like this really escapes me. I was reading an article about JavaScript, which apparently supports bitwise operations. I keep seeing this mentioned in places and I've tried reading about to figure out what exac...
If I am evaluating two variables and not two method calls does it matter weather I use "&&" or "&"
//some logic that sets bool values
boolean X = true;
boolean Y = true;
if (X & Y){
// perform some operation
}
if (X && Y){
// perform some operation
}
Further a book I am using for C# 3.0 / .NET 3.5 only makes reference to the ...
I posted this digital logic diagram as an answer to another stackoverflow question. It describes a logic system which will be coded in Verilog or VHDL and eventually implemented in an FPGA.
The numbered boxes in the diagram represent bits in a field. Each field has K bits, and the bits for current and mask will be provided by a comput...
I have a web page with an IFrame named "objFrame".
In a Javascript file, the following statement is executed:
var useWindow = (typeof(window.objFrame) != "undefined" && typeof(window.objFrame.contentWindow) != "undefined");
When running the code (normally or stepping through it with the debugger), the expression
(typeof(window.objFra...
I just want to flip a boolean based on what it already is. If it's true - make it false. If it's false - make it true.
Here is my code excerpt:
switch(wParam) {
case VK_F11:
if (flipVal == true) {
flipVal = false;
} else {
flipVal = true;
}
break;
case VK_F12:
if (otherVal == true) {
otherValVal = false;
} els...
#include<iostream>
using namespace std;
int main()
{
char again;
do
{
cout<<"you are in the while loop";
cout<<"do you want to continue looping?";
cin>>again;
}while(again!='n' || again!='N');
system("pause");
return 0;
}
i know something is wrong with the test condition in the 'while'. But i can't figure it out.
when the input o...
This runs in as3, and javascript. Why? I know how && and || work, but a list? is this as3 specific? Is this in other languages? I'm a mouth breathing PHP/AS2 programmer. Or did everyone already know this and I'm a tool for not reading documentation properly?
AS3
if (true, true, true) {
trace("true?")
}//result - "true?" traced...
I have an interesting question about the way PHP evaluates boolean expressions. When you have, for example,
$expression = $expression1 and $expression2;
or
if ($expression1 and $expression2)
PHP first checks if $expression1 evaluates to true. If this is not the case, then $expression2 is simply skipped to avoid unnecessary calcul...
I'm looking for a tool to refactor boolean expression. I've got expressions like
a1 => (b1 <=> c or d) AND
a2 => (b2 <=> c or d) AND
a2 => (b2 <=> c or d)
The tool should be able to simplify expressions, e.g. extract the sub expression "c or d" in the example above. Is there a free computer algebra system which can do this?
Currentl...
CF: Carry Flag
ZF: Zero Flag
i'm current read a book on intel x86 assembly on linux platform using AT&T syntax,and the book said,the effect of setbe D is qeuivalent to:
D CF & ~ ZF
i understood that,but could it simply write as:
D CF|ZF
this only different from ~ZF&CF when CF/ZF is either 1/1,or 1/0.which one is more accurate?
...
I've got a complex SQL where clause that just got more complex because of a requirements change. There are four basic sets of cases, each with a different combination of other factors. It's more readable (in my opinion) to have the four cases as separate branches of the where clause, and to repeat the redundant criteria in each branch. B...
Something any sophomore in CS should be able to answer, but I can't seem to wrap my head around it...
I have a set of bits, and I need to replace some of the bits with a different set. In a simplified example:
10101010 -original bit set
00001111 -mask showing replacement positions
00001100 -new bit values
10101100 -resulting bit se...
EDIT: Found duplicate once I learned the term for this behaviour. Close as duplicate please.
Consider this
Class* p = NULL;
if( p != NULL && p->Method() == OK ){
// stuff
}
On all compilers I've worked with, this is quite safe. I.e. the first part of the boolean expression will evaluate to false, and the call to Method() will thus...
AND, OR, XOR and NOT I understand. What I don't get are IMP and EQV. What do they mean? How'd they get in there? Is there any real use for them?
...
Currently, I'm using && and || instead of AND and OR because that's how I was taught. In most languages, however, both are valid syntax. Are there any advantages to one or the other in any language?
I did try to search for this question, but it's a bit hard. It doesn't interpret my input correctly.
...
I completely forgot about my Haskell project which is due in a couple of hours, any help would be appreciated.
The first part is an evaluation function that has the following type signature:
evaluate :: Logic Expr -> [(Variable, Bool)] -> Bool
This takes a logic expression and a list of assignment pairs as input and returns the value...
I need to make an application for creating logic circuits and seeing the results. This is primarily for use in A-Level (UK, 16-18 year olds generally) computing courses.
Ive never made any applications like this, so am not sure on the best design for storing the circuit and evaluating the results (at a resomable speed, say 100Hz on a 1....
Back in the day when I did most of my work in C and C++, as a matter of course, I would manually apply deMorgan's theorem to optimize any non-trivial boolean expressions.
Is it useful to do this in C# or does the optimizer render this unnecessary?
...