boolean-logic

Boolean Logic & gate delays

杀马特。学长 韩版系。学妹 提交于 2019-12-13 03:39:47
问题 Assuming 2 gate-delays for a Sum or Carry function, estimate the time for ripple-through carry addition for adders with the following word lengths:- i) 4-bit ii) 8-bit iii) 16-bit In my notes I have written: "delay is the word width times each bit stage delay (2 gate delays)". Therefore: i) 2*4 = 8 ii) 2*8 = 16 iii) 2*16 = 32 Looking at the ripple carry adder wikipedia page: http://en.wikipedia.org/wiki/Ripple_carry_adder#Ripple-carry_adder The formula used here is different, can anyone

How to test multiple variables against a value?

我怕爱的太早我们不能终老 提交于 2019-12-13 03:18:01
问题 I'm trying to make a function that will compare multiple variables to an integer and output a string of three letters. I was wondering if there was a way to translate this into Python. So say: x = 0 y = 1 z = 3 mylist = [] if x or y or z == 0 : mylist.append("c") if x or y or z == 1 : mylist.append("d") if x or y or z == 2 : mylist.append("e") if x or y or z == 3 : mylist.append("f") which would return a list of ["c", "d", "f"] Is something like this possible? 回答1: You misunderstand how

java && on if statement is not working

点点圈 提交于 2019-12-13 02:19:32
问题 I'm using this code to enable a button when both fields are filled in and disable it when they aren't: if (jTextFieldAccountName.getText().isEmpty() && jPasswordFieldAccountPassword.getPassword().length == 0) { jButton_Next.setEnabled(false); } else { jButton_Next.setEnabled(true); } But the button is enabled even if I type in only one of the fields. Why? 回答1: Your statement is working fine. The way you have it written, the button is going to be disabled only when BOTH fields are empty (if

Not able to figure out the logical error in C program

大兔子大兔子 提交于 2019-12-12 10:55:06
问题 A program that prints its input one word per line. int main() { int c; while ((c=getchar()) != EOF) { if (c== ' ' || c== '\n' ||c == '\t') putchar('\n'); else { putchar(c); } } return 0; } The above program prints the result correctly, one word per line. After changing the condition accordingly, I was expecting the program below to also print one word per line. However I am not getting the correct result. Am I making some silly mistake or is something wrong? int main() { int c; while ((c

Make subset of array, based on values of two other arrays in Python

两盒软妹~` 提交于 2019-12-12 10:51:37
问题 I am using Python. How to make a subselection of a vector, based on the values of two other vectors with the same length? For example this three vectors c1 = np.array([1,9,3,5]) c2 = np.array([2,2,3,2]) c3 = np.array([2,3,2,3]) c2==2 array([ True, True, False, True], dtype=bool) c3==3 array([False, True, False, True], dtype=bool) I want to do something like this: elem = (c2==2 and c3==3) c1sel = c1[elem] But the first statement results in an error: Traceback (most recent call last): File "

Logic Evaluator in c# (Evaluate Logical (&& ,|| ) expressions)

和自甴很熟 提交于 2019-12-12 07:19:51
问题 In my project there is a Logic evaluation section, it take input as a string which contains logical expressions ( true/false ) . I want to evaluate this string and return a final Boolean value. string Logic="1&0|1&(0&1)" //string Logic="true AND false OR true AND (false AND true)" This will be my Logic . The length might increase. Is there any way to Evaluate this expression from LINQ / Dynamic LINQ ? 回答1: a way without any third party libraries is to use a DataTable with expression. There

Recursive logic for parsing string into complex boolean?

那年仲夏 提交于 2019-12-12 03:46:50
问题 I'm sure this has been done before, I just can't find it. I need to turn something like, "((A OR B) AND C) OR D" into a database query for an attribute. Specifically I'm using Ruby Sequel. Can anyone point me at an example or utility or something that will keep me from reinventing the wheel? 回答1: You can define a grammar using ANTLR and automatically generate a Ruby parser for those type of strings. ANTLR is a parser generator and it allows you to define a grammar for a language (such as a

What's an “auto-casting bool”?

核能气质少年 提交于 2019-12-11 22:09:04
问题 On the following answer to a previous question someone mentioned an "auto-casting bool" I guess null has an auto-casting bool that is false. What is it, and what does the code that makes it look like? 回答1: The phrase "auto-casting bool" is a poor phrase someone used off hand. I believe what they mean is the internal ToBoolean operation Of special note is the if statement which calls ToBoolean on the expression. I don't know my way around the v8 source code but here is a search for ToBoolean

C#: Assign test result directly to variable

╄→尐↘猪︶ㄣ 提交于 2019-12-11 19:44:02
问题 Is it possible to assign the result of a test directly to a variable? I want to do something like c = ( a == b ) instead of if ( a == b ) { c = true; } else { c = false; } Is this possible? 回答1: Yes, of course. Which you can very easily test with the compiler. int a = 1, b = 2; bool c = a == b; 来源: https://stackoverflow.com/questions/18183591/c-assign-test-result-directly-to-variable

YouTube search operators in API call? booelan operator AND, OR and NOT

孤者浪人 提交于 2019-12-11 18:49:57
问题 i am having difficulty to discover how the operator AND function for a research with Youtube API. At the Youtube.Search i found the method setQ that explaing the logic for the operator NOT and OR but not for the operator AND. The main idea is to make a search that contains exactly both 2 parameters otherelse i can use the OR logic. Example: i want that 2 "fish" and "sea" should be both part of the metadata of the research. I have made an analysis on front-end call and it has this form: fish