Questions tagged [compare]

The analysis required to assess the differences and similarities between two or more entities.

This tag is used to classify a question as one dealing with the comparison of at least two entities. The essence of questions that are tagged should boil down to one of the following questions:

  1. How do I control when the compiler/interpreter thinks that two entities are equal? How do I control when the compiler/interpreter thinks that two entities are unequal?
  2. How do I control when the compiler/interpreter thinks that one entity is bigger than the other?
  3. How do I control when the compiler/interpreter thinks that one entity is smaller than the other?

Note that in some languages, it is possible to define asymmetric inequalities. That is, cases in which a<b does not mean that b<a. This is why in python, there exist separate functions for __gt__ (greater than) and __lt__ (less than), etc

10212 questions
2
votes
1 answer

User input for time and then comparing

Comparing the current time with a user input time WITHOUT the date So I'm making a lighting routine and I need to do some time comparisons to see if I'm in the middle of a cycle or out of a cycle. Long story short, I'm having issues comparing a user…
igomez
  • 39
  • 5
2
votes
1 answer

How does one compare a char variable to another char variable?

I'm working on a homework assignment in C where we need to make a tic-tac-toe game that can be played between two players. I have all of my code working at this point, except for the function that checks to find a winner. Here's an example of the…
bourgtai
  • 367
  • 1
  • 4
  • 9
2
votes
1 answer

Why does NA_real_ <= Inf return NA?

I am surprised by some of the values returned when comparing Inf and -Inf with NA_real_. Specifically: NA_real_ <= Inf #[1] NA -Inf <= NA_real_ #[1] NA The first sentence of the documentation for NA (help(NA)) is NA is a logical constant of length…
Ana Nimbus
  • 635
  • 3
  • 16
2
votes
2 answers

How to compare objects using operator < or > in Objective-C?

How do I compare two objects of a custom class in Objective-C? I try to overloading the - (NSComparisonResult)compare:(id)other; method. This works great if I call the method manually if ([obj1 compare:obj2] == NSOrderedDescending) { // do…
user691219
  • 173
  • 1
  • 4
2
votes
6 answers

What's the fastest way to compare two large lists of 1's & 0's and return the difference count/percentage?

I'm in need of a method to quickly return the number of differences between two large lists. The contents of each list item is either 1 or 0 (single integers), and the amount of items in each list will always be 307200. This is a sample of my…
AWainb
  • 868
  • 2
  • 13
  • 27
2
votes
2 answers

Python - finding complement of 2 lists

I'm looking for a method that would allow me to check what elements are missing when comparing 2 lists. A lot like in this thread but I want to write this in NumPy Python. Complement of Two Lists? import numpy as np numbers =…
michal-ko
  • 397
  • 4
  • 12
2
votes
2 answers

How to compare two characters without case sensitivity in C?

I am trying to compare two specific characters in two strings,but I want to make the comparing without case sensitivity. How can I do this? right now I am using a code like that: if (str1[i]==str2[j]) printf("Equal"); but I want to do this without…
Anthony
  • 69
  • 9
2
votes
0 answers

Compare two strings with multiple lines

I am having two strings. If the strings are equal then nothing to do , the else statement is fired. Just it works for in single-line format. but if the strings multiple lines like below then it does not work. Where am I do wrong ? For example…
Arbelac
  • 1,698
  • 6
  • 37
  • 90
2
votes
5 answers

PHP strpos() return empty value

I meet a strange thing with the PHP function strpos(). I have a function that check if a passed string is found in a txt file. I can display the content of the file line by line but the strpos() doesn't return a value (nothing in fact). var_dump()…
Ben
  • 31
  • 2
2
votes
2 answers

Compare each row string from columns and add condition to evaluate and print the result in new column

I have a dataframe as below string1 string2 var1 var2 T T 1 1 T F 0 1 F F 0 0 I want to iterate through each row which has n number of rows and add conditions like below Iterate n…
2
votes
4 answers

How do I compare the content of files in Python?

This is my code so far I'm trying to compare the files given by the user and printing if the content inside both files is the same. If it is the same string content I would like to print Yes if it's not, print No along with the words inside both…
Nanor
  • 79
  • 2
  • 7
2
votes
2 answers

Comparing two lists (check how many times short list occurs in long list)

I am doing homework and I got stuck with my code. The question is about two lists containing string letters in it as elements and we want to know how many times the small text occurs in the long one.(with order) Example: …
werlless
  • 49
  • 9
2
votes
2 answers

Compare lists in C# / Unity and ignore items

I am using Vuforia in Unity which has a built in script called DefaultTrackableEventHandler. It has a code like this; protected virtual void OnTrackingFound() { var rendererComponents = GetComponentsInChildren(true); …
Inori
  • 33
  • 4
2
votes
3 answers

SQL query Find all product which has increased value at certain 2 dates

I am wondering if I can do this using SQL query. I have a table called "data" which contains the product name, date and sale number. my table look like this: Product date Sale apple 1/1/2019 5 apple 2/1/2019 …
Max Cheung
  • 176
  • 3
  • 13
2
votes
3 answers

Compare two text files and write the differences to text file

I want to compare 2 text files and output the difference in another text file. $Location = "c:\temp\z.txt" compare-object (get-content c:\temp\hostname_old.txt) (get-content c:\temp\hostname_new.txt) | format-list | Out-File…
Arbelac
  • 1,698
  • 6
  • 37
  • 90
1 2 3
99
100