FAQ Database Discussion Community


Comparing two decimals

c#,comparison,decimal
I want to compare two decimals in c# with some margin of error. Can anyone point out problem with the following code. Note that I am interested in 6 decimal places after that I could ignore the values. var valOne = decimal.Round(valueOne, 6); var valTwo = decimal.Round(valueTwo, 6); var difference...

Compare two instances of an object in Swift

class,swift,object,comparison
Given the following class, how can all the values in two instances be compared to each other? // Client Object // class PLClient { var name = String() var id = String() var email = String() var mobile = String() var companyId = String() var companyName = String() convenience init...

python:compare values with other values in dictionary [closed]

python,loops,dictionary,random,comparison
As per this link now i have to Randomly choose state as question and compare the answer with capital, if user provides right answer loop must exit. I have a dictionary with {'state': ['Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California'], 'capital': ['Montgomery', 'Juneau', 'Phoenix', 'Little Rock']} ...

Can I use « is » to compare against static variables?

python,enums,comparison,identity,static-variables
Python's PEP 435 about the enum module says that enumerators should be compared with is instead of the usual ==. I guess that the reasoning is that an enum members are static and won't ever change, so it makes sense. I am using Python 2.7.9 for compatibility reasons and I...

How to compare date in string with sysdate in Oracle?

oracle,date,comparison
I am new with Oracle and still get used to SQL Server. I do not understand on why the command below would return '1' when clearly sysdate which is today is 29-Apr-15 that clearly before 30-Apr-15 It should return 0. But I do not understand why it returns 1. Any...

conversion from 'uint64_t' to 'unsigned int'

c++,visual-studio,comparison
For the following function in Microsoft Visual Studio 2015 RC, I get two warnings regarding the comparison of signed and unsigned variables. uint64_t findMin(vector<uint64_t> &v) { uint64_t min = 0; uint64_t s = v.size(); for (uint64_t i = 0; i < s; ++i) { if (v[i] != 0) { //...

Comparison between two objects under the same class

c++,comparison
I am still new to C++ (programming in general)and forgive me if this question is stupid or has been asked numerously. Here is the question..Let's say there are two objects A and B under the same class. e.g class Fruit{ int apple; int banana; fruit(int x, int y){ apple=x; banana=y;...

SELECT where date is within X months away regardless of stored year

mysql,sql,date,comparison
I currently have a query that is getting the records where their deadline is less than 3 months away. The deadline is stored as a Date, but the year is not important as this record should flag up every year. My query: SELECT client_name FROM client WHERE MOD(DAYOFYEAR(deadline) - DAYOFYEAR(CURDATE()),...

Using Linq to compare a list with a set of lists in C#

c#,linq,list,comparison
I have a website containing news stories. Each story has a list of tags associated with it. Other pages on the site also have a list of tags. On one of the other pages I want to list all the news stories that have one or more tags in common...

Numpy matrix row comparison

python,performance,numpy,matrix,comparison
The question is more focused on performance of calculation. I have 2 matrix with the same number of columns and different number of rows. One matrix is the 'pattern' whose rows have to be compared separately with the other matrix rows (all rows), then to be able to extract statistical...

R: Comparing the presence of a string in multiple dataframes

r,comparison,data.frame
I have 6 dataframes: DvE.+ DvE.- DvS.+ DvS.- EvS.+ EvS.- and they all have similar structure: gene FDR log2FC annotation 10 c10001_g1_i1|m.32256 4.638831e-02 -0.9888892 [Genbank]glutaredoxin/malate transporter fusion protein [Chlamydomonas reinhardtii] 33 c10006_g3_i4|m.32310 7.826191e-07 -1.3364432 [Tigrfam]ChlG: chlorophyll synthase ChlG 47 c10010_g1_i4|m.32346 8.609296e-15 1.9188013 [Genbank]conserved unknown protein [Ectocarpus siliculosus] 48 c10010_g1_i4|m.32348 5.625766e-09...

Comparing values after ChangeType not working

c#,if-statement,integer,comparison,changetype
I have the problem, that comparing values after changing the type (in this case to int) does not work: In my point of view (see the debugger), _pkValue and _defaultValue are both integers with the same value. The problem is, that the if-statement should not be entered, because both values...

PHP compare 2 arrays (Mac donalds and Burger King)

php,html,checkbox,sum,comparison
I have to make a comparison site for the products from MC and BK. http://informaticaphp.net84.net/home.php <- that's how far I am. This is the code : <html> <head> <link rel="stylesheet" type="text/css" href="style1.css" /> </head> <?php if(isset($_POST['formSubmit'])) { $breakfastMC = $_POST['BreakfastMC']; $breakfastBK = $_POST['BreakfastBK']; if(empty($breakfastMC)) { echo("<p>You didn't select any food.</p>\n");...

What is faster: equal check or sign check

java,performance,comparison,equality,cpu-architecture
I wonder which operation works faster: int c = version1.compareTo(version2); This one if (c == 1) or this if (c > 0) Does sign comparasion use just a one bit check and equality comparasion use substraction, or it is not true? For certainty, let's say we work on x86. P.S....

Does order of compared literals matter if both are evaluated? [duplicate]

java,if-statement,comparison
This question already has an answer here: Boolean equal: 0 == a, does operand order matter? 6 answers I have a rather stupid question. The point is, I often see an if statement looking like this: private int smth; // ... if (3 == smth) // ... The order...

Trying to compare a value to multiple, multiple dimension arrays

arrays,excel,vba,comparison
I have a spreadsheet of data in multiple columns. In VBA, I am trying to set a value in each row depending on the data in any one of three of the other columns. It will always be an OR comparison between those data and will need to return one...

Best way to detect changes when values might not exist anymore?

javascript,jquery,jquery-ui,comparison,concatenation
I've been trying to detect changes in multiple inputs on a web page. To do that, I used a query like this: $(.InputClass).data("InitialValues",$(.InputClass).serialize()) (I'm not in front of my code sadly but it should look like this) Then later I compared the values in .data with the new values and...

Why does comparing Integers by reference (==) work?

java,comparison,operators,equality
In Herbert Schildt's "Java: The Complete Reference, 9th Edition", there's an example that kinda baffles me. Its key point that i can't comprehend could be summed up to the following code: class Test { public static void main (String args[]) { Integer i1 = 6; Integer i2 = 6; Integer...

Conditionally change GetHashCode() when comparing two objects

c#,.net,performance,comparison,gethashcode
I have two different lists of objects and want to get their similarities, based on the weight of some of the properties. Quickest way seems to be with implementing an IEquatable interface and that is what have I done: public class CompareEntry : IEquatable<CompareEntry> { public int LeadId { get;...

In JavaScript, is there any difference between typeof x == 'y' and typeof x === 'y'?

javascript,performance,comparison,undefined,typeof
I'm aware of the difference between strict and loose comparison operators. Clearly x == y is different from x === y. But whenever I see code that uses typeof, it always uses ===. If the typeof operator always evaluates to a string (such as 'boolean', 'number', etc.), then wouldn't typeof...

Custom String Deficiency

c++,string,char,comparison
So my problem currently is when I do a comparison with a modified string value, and a string value that has not been modified, I do not get the expected result of true, but a false. I have overloaded the logical comparison operator, but that's not what I want to...

Java 8: More efficient way of comparing lists of different types?

lambda,comparison,java-8,java-stream
In a unit test, I want to verify that two lists contain the same elements. The list to test is build of a list of Person objects, where one field of type String is extracted. The other list contains String literals. One often finds the following code snippet to accomplish...

Comparing the InnerHTML of an object in jQuery

javascript,jquery,dom,comparison,sharepoint-2013
I am able to get the .html() of a SharePoint textbox, which in the DOM simply appears as a <div>. When the textbox is empty, the InnerHTML of that <div> simply appears as <p></p>. Because this particular textbox does not always appear (I control its appearance based on the selected...

How to compare matrix elements to treshold in NumPy

numpy,matrix,comparison
I have a matrix of positive values, as well as a list of tresholds. The list of tresholds is sorted. For example X = np.matrix([[1., 2., 3.,], [0., 2., 1.], [4., 1., 2.]]) y = [0.5, 1., 3., 5.] I would like to write a function that sets all entries...

Apache Hadoop vs Google Bigdata

hadoop,comparison,hdfs,bigdata,gfs
Can any one explain me the key difference between Apache Hadoop vs Google Bigdata Which one is better(hadoop or google big data). ...

Why Comparison Of two Integer using == sometimes works and sometimes not? [duplicate]

java,types,comparison
This question already has an answer here: Why does 128==128 return false but 127==127 return true in this code? 4 answers Why equal operator works for Integer value until 128 number? [duplicate] 7 answers I know that i am comparing reference while i'm using == which is not a...

Python : How to optimize comparison between two large sets?

python,list,optimization,comparison,nlp
I salute you ! I'm new here, and I've got a little problem trying to optimize this part of code. I'm reading from two files : Corpus.txt -----> Contains my text (of 1.000.000 words) Stop_words.txt -----> Contains my stop_list (of 4000 words) I must compare each word from my corpus...

How do I match a date from a list of dates in excel?

excel,excel-formula,comparison
I need to compare two dates to see if they are equal from a list of dates in a column. Eg. Sheet 1 Column A Date 1 Date 2 Date 3 Date 4 Sheet 2 : Row F: Date 5 I want to see if date 5 is equal to...

Using the !== Operator to compare strings taken froma Dropdown list - Javascript

javascript,comparison,operators
I'm trying to get q1check to read a value from the dropdown form item 'qq1'.' It's reading it in fine. There seems to be an issue with the way I'm using the comparison operators. Could anyone help me? function q1ans_check(){ var q1check = document.getElementById("qq1").value; alert(q1check); if(q1check !== "1" || qlcheck...

bash while loop comparison not evaluating

bash,comparison,operators
I am trying to understand the difference between coding for if and while statements in bash. In the script below, if I use IF I get the expected result using == OR -eq etc. However with the while loop each while seems to evaluate as true for all tests. While...

Comparison != doesnt work like I expect

python,comparison,control,operator-keyword,flow
I have this: salir = "" while salir != "s" or salir != "S": print("no has salido") salir = input("Digit s to exit or enter to continue) print("saliste") but the operator != doesnt work, but if I put this: salir = "" while not (salir == "s" or salir ==...

Trouble in a program to convert between currencies in C++

c++,if-statement,comparison
I've made a simple program in C++ to convert between currencies, as part of a lesson. It asks for a numerical value and then a letter (y, e or p) to represent one of the supported currencies. When using 'y' or 'p' you can input the numerical value and character...

find type equality in one array or list and perform operation. C#

c#,arrays,types,comparison
how can i find type equality in one array. or list i am using these classes: public class Expression { public Expression[] Par { get; } public string Opr { get; } public Expression(string opr,params Expression[] par) { Opr = opr; Par = par; } protected Expression() { } }...

String comparison in ksh never succeeding

variables,comparison,ksh
I have the next script, and when trying to compare variable value if equals "NO" or "SI" (yes in spanish) it's not working for some reason I keep going all the time through the else (SI) although the real value in the variable is "NO". It's even being printed in...

MIPS - is there a way to transfer the value of the flag in coprocessor 1 to integer registers of coprocessor 0?

assembly,floating-point,comparison,mips,spim
I'm making a compiler for a school project and I am using MIPS assembly as my target code. But that's not important. I know that operations involving floating-point numbers are done in coprocessor 1 and that result of comparison instructions like c.eq.d and c.le.d are in the flag that can...

Comparing an object with a String using equals() method

java,language-features,comparison
In the below example, I am expecting equals() to return true: public class flower { String flower; public flower (String flower) { this.flower = flower; } public static void main(String[] args) { flower one = new flower("Flower"); boolean isSame = false; if(one.equals("Flower")) { isSame = true; } System.out.print(isSame); } }...

Is there a detailed comparison between Propel 2 and Doctrine 2

performance,orm,doctrine,comparison,propel
From the existing comparisons between 1.x versions of Propel and Doctrine, I couldn't decide whether to use Doctrine 2.x or Propel 2.x for my new project. I have some experience with Propel but am not happy with the way Propel 2 broke compatibility with previous versions. Hence this question. Is...

MySQL Comparison Query

mysql,comparison
I need to compare all regions and show the better regions about the score. For example if I want to see Asia's Score Comparison; I will see only the better regions about the score. (better regions: North America, Europe) select Destination_Region, count(1) as Score from pro11 where Destination_Region is not...

How to compare mac-addresses in Perl

perl,comparison,mac-address
I had two mac addresses 12-23-34-RT-43-23 and 12:23:34:rt:43:23. How to compare these two mac address in Perl. Are there any libraries to compare?

compare “int* pointer” with constant memory adress

c,pointers,memory,comparison,microcontroller
How can i compare a pointer value with a constant memory address? #define ADR 0x2000 unsigned int * po; if(po<ADR) { }; Above code works but it gives a warning "comparison between pointer and integer"...

Finding a document in RethinkDB that meets multiple criteria

function,comparison,rethinkdb
I want to create a wrapper function that accepts an array of requirements. This wrapper function will ask rethinkDB for any documents that meet all criteria. The values will be numerical and I want anything returned which has >= the asked for value. The syntax supplied in the API is...

String Comparison from text file does not return anything

string,comparison,buffer
i am a beginner in Java, i was trying to read a text from a text file and compare it to Strings i created within my class, for some reason it does not output anything on the console and i can't help but wonder why. Here's my simple code package...

why the following code gives the first mobile no. irrespective of name

c,string,switch-statement,comparison
Please explain why the following code gives the first mobile no. irrespective of entered name: #include<stdio.h> #include<conio.h> int mobileno(char[]); int main(){ char input[20]; gets(input); printf("%s",input); int x; x = mobileno(input); printf("%d",x); switch(x){ case 0:printf("7255222319");break; case 1:printf("9404521113");break; case 2:printf("9326513553");break; case 3:printf("9845621611");break; case 4:printf("4556312390");break; case 5:printf("9245178190");break; case 6:printf("9214188214");break; case...

Perl: check in hash if all entries are equal, get an arbitrary/random key from hash

perl,hash,comparison
The goal: I want to check if all entries in a hash are equal in some manner (here it's the count). My nasty solution: # initialize some fake data my @list1 = (2, 3); my @list2 = (1, 2); my %hash = (12 => \@list1, 22 => \@list2); # here...

testing dynamically created strings

javascript,algorithm,comparison,func
what i have now is a function that return an array of 2 string that were put together using a random number generator. those values will help make up a string like "this is" + v1 + " and this is" + v2. v1 and v2 are the dynamically created...

Theoretically, is comparison between 0 and 255 faster than 0 and 1?

performance,comparison,bit,low-level,machine-code
From the point of view of very low level programming, how is performed the comparison between two numbers? Using one byte, unsigned numbers 0, 1 and 255 are written: 0 -----> 00000000 1 -----> 00000001 255 ---> 11111111 Now, what happens during the comparison between these numbers? Using my vision...

PHP strict compare two objects is false

php,arrays,object,comparison
$a = new stdClass; $a->first = 'James'; $a->last = 'Doe'; $b = (object) [ 'first' => 'James', 'last' => 'Doe', ]; echo 'Loose compare: ' . ($a == $b ? 'equal' : 'different') . PHP_EOL; // equal echo 'Type compare: ' . (gettype($a) == gettype($b) ? 'equal' : 'different') ....

PHP Loose comparison and null on Switch

php,null,switch-statement,comparison,case
Today I saw a strange bug on my code. I have a switch with comparison on case and if my variable equals null or '' it will always comes in the first case. My code : $sHost = filter_input(INPUT_SERVER, 'HTTP_HOST'); switch($sHost){ // Local case strpos($sHost, "dev.localhost") !== false: $this->_sEnv =...

Can I assume NULL value in comparison as the false?

c,pointers,comparison,condition,null-pointer
I know that NULL == (void *)0 but it is mentioned that it can be represented as a value which doesn't contain all zeros. What bothers me is if those pieces of code are equivalent for all (any_type *): any_type *val; if (val) { ... }; and if (val !=...

Why does this string extension method not throw an exception?

c#,null,comparison,ienumerable,argumentnullexception
I've got a C# string extension method that should return an IEnumerable<int> of all the indexes of a substring within a string. It works perfectly for its intended purpose and the expected results are returned (as proven by one of my tests, although not the one below), but another unit...

Global class comparison with inheritance

c++,class,inheritance,comparison
I am writing global class comparison functions with operator== for a large framework where classes tend to inherit several classes or have deep inheritance (class A inherits from B, B inherits from C, etc.). In order to make things manageable I figured I would have a comparison functions for base...

Compare two DATETIME fields from multidimensional array and return a value or index

php,mysql,arrays,multidimensional-array,comparison
I have a user table. I have 2 DATETIME per row that I'm looking at. I will look at $lastLog date and $lastReceived (for last received lead) and determine which is newer and that becomes their $eligibleTime. We will then look for the oldest $eligibleTime to select which user should...

How to test comparison if input will be truncated?

c,integer,comparison
So I have something cast as an int, and from my understanding maximum value for an int is 32676, and any value above this will be truncated in C. If my program has the user inputting data, how can I check if this data can be fully stored in an...

Using comparable to compare different variables

java,libgdx,comparison,comparator,comparable
I'm familiar with standard comparisons using the Comparable interface, although today I'm having some trouble when I want to compare several different variables. I basically want to implement a compareTo method that yields the result -1 only when the following if statement is true: if (o.maxX > minX && o.maxY...

Char Comparison in Common Lisp

sorting,char,comparison,lisp,common-lisp
How can i compare characters with Common Lisp? I have google it and found out that there are some functions to do the comparison, like char=, char/=, char<, char>, char<=, and char>=. But, i can't use all of the functions just like: (char= 'a 'a) (char< 'a 'b) If i...

Comparison method violates its general contract when sorting

java,sorting,comparison
I keep getting: Comparison method violates its general contract! Exception for the below compare function when I call Arrays.sort(ScreenItems) One assumption I have is that the ParseInt below is throwing an exception for the left object but not to the right object Could that be the case? public int compare(Object...

How do I only send the differences between two images over the network? [duplicate]

c#,image,sockets,stream,comparison
This question is an exact duplicate of: Sequential PrintScreens Comparison, Generate a difference image? 1 answer I am making a program which sends images (actually screenshots) over a tcp connection by serializing the byte array (of course after a conversion from image to byte array) to a network stream....

Ruby comparing biggest potential number

ruby-on-rails,arrays,ruby,comparison
Quick one. i have an array [92,901] i want to arrange these so that if they were compacted together they would generate the biggest potential number. in this case it would be 92 then 901 to make 92901. These numbers could be huge as well and there could be many...

count how many times characters from a range occur in a string

string,bash,comparison
So I'm kinda new to bash and scripting in general. I'm a student and we've been given an assignment to create a password checker that checks whether or not the arguments at $1 of the command meet the password criteria. If $1 is blank, the script should generate an acceptable...

Comparing two images as being identical?

image-processing,comparison,dm-script
This might be easy, but I'm still struggling a bit. How do I compare two images if I want to find out if they are identical? Say I have an image A and and image B I want to do something like if ( A == B ) ... but...

Python Pandas: How to groupby and compare columns

python,pandas,group-by,comparison
Here is my datafarme 'df': match name group adamant Adamant Home Network 86 adamant ADAMANT, Ltd. 86 adamant bild TOV Adamant-Bild 86 360works 360WORKS 94 360works 360works.com 94 Per group number I want to compare the names one by one and see if they are matched to a same word...

“==” not doing what i think it should do in Python [duplicate]

python,comparison
This question already has an answer here: python lxml tree, line[] creating multiple lines, desire single line output 1 answer In a script im working on I do the following: data["serial"] = md5.new(json.dumps(data["data"])).hexdigest() ... ... lst = serialFile.readlines() if(len(lst) > 0): lastLine = lst[len(lst) - 1] ... ... print...

Compare code from the files of two directores [closed]

php,ftp,compare,comparison
I have several files & folders in domain.com and a working copy in: domain.com/beta I want to compare the code of all files (php files) in the beta folder with the ones in the main folder and just view the files in which the codes do not match. I've googled...

Compare two arrays for a value

php,arrays,comparison
I have two arrays which hold some data which defines whether a user has access to this article. The article will be tagged to a client i.e. ClientA, ClientB and the User when created will be assigned a client access tag. I want to compare both the arrays and if...

Compare two System.Enum of type T

c#,generics,enums,comparison
I am pretty close to understand Generics now (I think). However, just figured that System.Enum is not easy to implement as a generic type. I have this class: public class Button<TEnum> where TEnum : struct, IConvertible, IComparable, IFormattable { public TEnum Identifier { get; private set; //Set in the ctor...

VBA copy rows after comparing column data

excel,vba,comparison
Okay hi everyone, again. So I have already posted several similar questions but to no avail.. I decided to post another one as I think it would be pretty messy to keep commenting below. The links for my previous questions are here and here I decided to try and change...

How to compare two arrays in mysql query?

php,mysql,arrays,comparison
I have a table named mm_test like follows:- id educations 1 3,4,6,8,9 I want to check whether this array contain (4,6). How to check this using mysql query. Mysql 'IN' command is not working for me. I put the query like this... select * from mm_test where educations IN (4,6);...

Comparing multidimensional arrays using specific key in php

php,arrays,multidimensional-array,comparison,array-difference
I have two multidimensional arrays. the first one is: Array ( [0] => Array ( [username] => J1 [fullname] => John1 ) [1] => Array ( [username] => K1 [fullname] => Kate ) [2] => Array ( [username] => P1 [fullname] => Peter ) [3] => Array ( [username] =>...

Python: Searching a specific columns of a table for not matching items

python,csv,table,comparison
with open("test.txt", "r") as test: reader = csv.reader(test, delimiter="\t") writer = csv.writer(table, delimiter="\t") for row in reader: for field in row: if field not in keywords: writer.writerow(row) break It seems that this code writes out every row multiple times. I guess that it looks up every single field in each...

Error while comparing data fetched from the table

php,mysql,arrays,error-handling,comparison
I am not sure what's wrong, but it gives the error message- Error1: "Notice: Undefined index: user_type" and Error2: "Notice: Undefined index: user_approved", while there exists a table userdetails which has columns with the name user_type and user_approved. NOTE: The code may be incomplete, but it has nothing to do...

C - Why compare constants with & instead of switch/if?

c,switch-statement,comparison,ampersand,opensl
I am reading the OpenSL documentation for Android. Quoting the following document: http://mobilepearls.com/labs/native-android-api/ndk/docs/opensles/ "Callback handlers should be prepared to be called more or less frequently, to receive additional event types, and should ignore event types that they do not recognize. Callbacks that are configured with an event mask of enabled...

ACL “fuzzy” comparision

arrays,powershell,comparison,powershell-v2.0
I'm trying to compare ACLs on a folder with a reference set of ACLs, and then list any exceptions. The "fuzzy" part of the equation is that I want to be able to disregard any unknown SID. So creating a reference folder with the perms I want to test won't...

Javascript: Compare backgroundColor set by javascript

javascript,css,background,comparison
How can compare the background color of an element, when the color is set with javascript, I want a function that toggles the backgroundColor: function toggleBgColor() { if(document.getElementById("id").style.backgroundColor === "blue"){ document.getElementById("ide").style.backgroundColor = "red"); }else{ document.getElementById("ide").style.backgroundColor = "blue"); } } The problem is that the comparison is always false, so my...

PHP Comparing 0 does not work

php,loops,comparison
I'm trying to set a checkbox as checked in php based on an hour fields from a comma separated value string. It works well for 1-23 but for some reason hour 0 always displays as checked: <?php myhours = explode(",", substr($arruser['arhours'],0,strlen($arruser['arhours']) - 1)); $checked = ""; for($hour = 0; $hour...

How could I compare two data sets of X,Y coordinates to look for similarities?

javascript,authentication,comparison,coordinates,gesture-recognition
Pretty abstract question, but I'm conducting some research on gesture-based recognition. I've managed to get the gesture to be outputted into a series of X,Y coordinates that I can view as a scatter graph: Here's my problem; I'm unsure on how to proceed. What is the best way to compare...

is it safe to use comparison operators on BigDecimal in groovy/grails?

groovy,comparison,operator-keyword
The Java way to compare two BigDecimals is to use the compareTo() method, and check if the result is -1, 0 or 1. BigDecimal a = new BigDecimal("1.23") BigDecimal b = new BigDecimal("3.45") if (a.compareTo(b) > 0)) { } I have seen that some people are using this format in...

Comparing float values in bash

bash,if-statement,comparison,bc
Hi I would like to compare 2 float numbers in bash but I haven't find anything that works properly. My actual code is the following: if [ $(echo " 0.5 > $X " | bc -l )==1 ] echo grande fi if [ "$(bc <<< "$X - 0.5")" > 0...

How to check string is laid out in correct format (Python)

python,string,comparison
I am coding a program which needs to import log files. The user must input the name of the file in the correct order of 'DD-HH.MM' (day, hour, minute). Is there any way to validate that the users input is in the correct order? Thanks in advance...

Python, comparison sublists and making a list

python,comparison,append,sublist
I have a list that contains a lot of sublists. i.e. mylst = [[1, 343, 407, 433, 27], [1, 344, 413, 744, 302], [1, 344, 500, 600, 100], [1, 344, 752, 1114, 363], [1, 345, 755, 922, 168], [2, 345, 188, 1093, 906], [2, 346, 4, 950, 947], [2, 346,...

Using Comparison Operators correctly

javascript,html,comparison,operators
I am new to HTML and have used Eclipse for Java before. Below I am trying to have the user input a number (0-5) and have the computer try and guess it. I have looked this over and it seems sound, the only thing that I have never done is...

get buffer contents, store it in struct, get new buffer contents see if equal in struct

c++,c,arrays,struct,comparison
I've been learning c++ for about a couple months now...I made a smaller program to see where I'm going wrong in a bigger program.... I'm taking information from a buffer[] and storing it in a struct. When the buffer's information changes, I want to check in the struct to see...

python merging pairs lists within sublists within a list by comparing previous pair's second number with next pair's first number [duplicate]

python,list,for-loop,merge,comparison
This question already has an answer here: Merging a list of time-range tuples that have overlapping time-ranges 4 answers [[[0, 2], [2, 9]], [[3, 7], [7, 9], [9, 12], [15, 17]], [[4, 6]]] I need to iterate through this list of sublists of list pairs and check whether the...

Python compare tuples with different data types but same values

python,comparison,tuples
I am trying to compare two tuples to determine if there is any difference. The code I use is not solving my problem because I do not care about if value has different types. In the example I do not care if value "1" is string or integer. I would...

Python: __cmp__ and testing list membership

python,comparison
Apologies if someone has already addressed this, but I couldn't find an answer. I have a problem where I overrode __cmp__ for a custom class, similar to this: class MyClass(object): def __init__(self, prop): self.prop = prop def __cmp__(self, other): return cmp(self.prop, other.prop) a = MyClass(1) b = MyClass(2) c =...

Python: How would I compare two strings using a function with only one of the strings as an argument?

python,string,comparison
I've created a class, and I am unsure how to approach the following problem. Is it possible to create a function that will be able to do what is in the example? (For practical uses, I would be comparing dates and returning true if the day and month are the...

How to compare signal to zero in vhdl?

comparison,vhdl,comparator
I have signal: signal sig: std_logic_vector(N - 1 downto 0); Where N defined in generic, and can be from 16 to 1024. In code i need to compare this to zero: if unsigned(sig) = 0 then do somth end if; But how can I know which delay would be of...

Comparing two excel Sheets using VBA

excel,vba,excel-vba,comparison
I have a list of addresses in column A of both sheets. sheet1 and sheet2 I'm just wondering is there an efficient way to compare data in two sheets and do the following; Remove addresses from sheet1 that are not in sheet2. Add the addresses from sheet2 that are not...

Ruby: matching a string against another object that may be a string or regexp

ruby,regex,string,comparison
I'm writing a routine that compares a string against a list of objects, each of which may be either another string or a RegExp. Is there an elegant, ruby-centric way to handle this? For now, I'm doing something like this: def compare(str, thelist) thelist.any? do |item| case str when item...

Comparison between one observation and the others by level of a factor

r,comparison
Sorry about the vague title, but I cannot figure out how this operation is supposed to be called. I guess it could be a leave-one-out process, but I'll explain. I have this: structure(list(Ident = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("A_1_2",...

Which is the quickest of prime generating algorithms?

performance,algorithm,comparison
I was working on an algorithm in Java to find all primes up to a certain number. It was supposed to be an improvement of an earlier method of doing so, which was the following: public static int[] generatePrimesUpTo(int max) { int[] primes = new int[max]; primes[0]=2; int p =...

Batch - Comparing two txt files

windows,batch-file,text,comparison
I have some difficulties comparing two txt files with batch. I used the "findstr" function with many option matchings but none works (for example FINDSTR /I /V /B /G:file1.txt file2.txt). I have a first txt file as following: File1.txt Object 1 Argument 50 Object 2 Argument 10 Object 3 Argument...

VB.Net Double comparison after some additions

vb.net,comparison,double
I've faced a weird case with a double variable after adding some values to it. The problem occurs when adding (0.2) to a double variable more than one time -I think it only happens with (0.2)- for example: consider this code: Dim i As Double = 2 i = i...

Write the condition - only one of three numbers are multiple of 5

java,math,numbers,comparison
There should be <=3 comparison operators and no extra parentheses. So condition = x % 5 == 0 ^ y % 5 == 0 ^ z % 5 == 0; Doesn't test right when X, Y and Z are both multiple of fives...

How can I compare two array lists for equality with a custom comparator?

java,generics,collections,comparison
To be specific, I have two lists: List<SystemUserWithNameAndId> list1; List<SystemUserWithNameAndId> list2; I want to check if they contain the same system users and ordering is not an issue. I tried to use a comparator to sort them first and then check if they're equal using the equals() method of lists....

Excel VBA: Compare Date to List & Return Next Date In List

excel,vba,date,comparison
I am back with another one that I'm not quite sure how to do. As previously stated I am a beginner VBA programmer so a lot of things are not obvious to me. Anyway what I am trying to do is: Have the user select a paygroup number from a...

Comparing cell contents against string in Excel

string,excel,if-statement,comparison
Following is my table file:*.css file:*.csS file:*.PDF file:*.PDF file:*.ppt file:*.xls file:*.xls file:*.doc file:*.doc file:*.CFM file:*.dot file:*.cfc file:*.CFM file:*.CFC file:*.cfc file:*.DOC I need a formula to populate the H column with True or False if it finds column G in column F (exact case). I used following but nothing seems to...

Does __ne__ use an overridden __eq__?

python,comparison,equality
Suppose I have the following program: class A(object): def __eq__(self, other): return True a0 = A() a1 = A() print a0 != a1 If you run it with Python the output is True. My question is the __ne__ method is not implemented, does Python fall on a default one? if...

PHP strings have same encoding (UTF8) and appear as identical in browser but are not equal

php,string,curl,utf-8,comparison
so I need to compare to strings (1 is a result from a CURL call to a remote URL, using charset UTF8) and the other is hardcoded in my script (utf8 as well). The strings look the same but when I compare them using strcmp(), the result is -44. I...

Java interface to compare various data types

java,comparison,comparable
I need to have an interface that will allow this to work for all data types if implemented with generics. Something to this effect. if (myIter.myDataType < SearchDataType){ return myIter; } or if (myIter.compareTo(SearchDataType)){ return myIter; } needs to work with integers, char, strings and even Boolean if possible. I'm...

AM/PM comparison in PHP [duplicate]

php,date,datetime,time,comparison
This question already has an answer here: Comparing dates giving incorrect outputs 2 answers $star_time = "2015-05-15 09:30 PM"; $end_time = "2015-05-15 09:40 AM"; when comparing these two date/time it's showing that $end_time bigger than $star_time when $star_time actually is bigger because the time at night while $end_time in...