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
31
votes
4 answers

How to compare two regexps?

Why do console.log(/a/ == /a/); and var regexp1 = /a/; var regexp2 = /a/; console.log(regexp1 == regexp2); both return false?
sp00m
  • 47,968
  • 31
  • 142
  • 252
30
votes
1 answer

What happens when you compare 2 pandas Series

I ran up against unexpected behavior in pandas when comparing two series. I wanted to know if this is intended or a bug. suppose I: import pandas as pd x = pd.Series([1, 1, 1, 0, 0, 0], index=['a', 'b', 'c', 'd', 'e', 'f'], name='Value') y =…
piRSquared
  • 285,575
  • 57
  • 475
  • 624
30
votes
4 answers

How to compare multidimensional arrays in C#?

How to compare multidimensional arrays? Just true/false. double[,] data1 = new double[,] { { 1, 2 }, { 3, 4 }, { 5, 6 }, { 7, 8 } }; double[,] data2 = new double[,] { { 1, 2 }, { 3, 4 }, { 5, 6 }, { 7, 8 } }; //bool compare =…
Yura G
  • 586
  • 1
  • 7
  • 13
29
votes
6 answers

How to compare just the date part and not the time of two Dates?

I want to compare just the date part (and Not the time) of two VB.NET Date objects. Is there a way to do that?
Ylva D
  • 355
  • 1
  • 4
  • 10
29
votes
13 answers

Compare XML ignoring order of child elements

Does anybody know of a tool that will compare two XML documents. Belay that mocking… there’s more. I need something that will make sure each node in file 1 is also in file 2 regardless of order. I thought XML Spy would do it with the Ignore Order of…
Andrew Garrison
  • 6,977
  • 11
  • 50
  • 77
29
votes
10 answers

Comparing two integer arrays in Java

I am trying to write code to compare two arrays. In the first array I have put my own digits, but the second the array takes numbers from the input file. The size of this array is determined by the first number in the file while the first array is…
user2052514
  • 467
  • 1
  • 4
  • 9
29
votes
3 answers

Comparing strings lexicographically

I thought that if I used operators such as ">" and "<" in c++ to compare strings, these would compare them lexicographically, the problem is that this only works sometimes in my computer. For example if("aa" > "bz") cout<<"Yes"; This will print…
slugo
  • 1,019
  • 2
  • 11
  • 22
28
votes
4 answers

How to compare strings

I wanted to compare a string without actually defining one of them as a string, something like this, if (string == "add") Do I have to declare "add" as a string or is it possible to compare in a similar way?
Anon
  • 347
  • 2
  • 4
  • 8
28
votes
5 answers

[] == ![] evaluates to true

I would like to know why the expression given in the title [] == ![] is evaluated to true. You cannot compare arrays as strings. I get that. If [] == [] will evaluate to false because the references are different. Though if we have the following…
Tek
  • 1,178
  • 1
  • 12
  • 22
27
votes
1 answer

Difference between previoussibling and previouselementsibling-javascript

I wonder if I know What is the difference between javascript previousSibling and previousElementSibling. I tried and I didn't find any question or article that compare or describe this. Maybe this is for my little javascript knowledge, but I…
QMaster
  • 3,743
  • 3
  • 43
  • 56
27
votes
11 answers

Check if string contains word in array

This is for a chat page. I have a $string = "This dude is a mothertrucker". I have an array of badwords: $bads = array('truck', 'shot', etc). How could I check to see if $string contains any of the words in $bad? So far I have: foreach…
user1879926
  • 1,283
  • 3
  • 14
  • 24
27
votes
1 answer

How to compare two directories using diff while ignoring non-existing files?

I would like to use diff to compare two directories for differing files, using the -q option for brief output. However, the output is cluttered with a lot of files that only exist in one directory, but not the other. Can I force diff (or use another…
26
votes
6 answers

Compare multidimensional arrays in PHP

How can I compare multidimensional arrays in php? Is there a simple way?
Kevin
  • 489
  • 2
  • 5
  • 15
26
votes
13 answers

Compare two dates in Java

I need to compare two dates in java. I am using the code like this: Date questionDate = question.getStartDate(); Date today = new Date(); if(today.equals(questionDate)){ System.out.println("Both are equals"); } This is not working. The content…
Gnaniyar Zubair
  • 8,114
  • 23
  • 61
  • 72
26
votes
3 answers

I want to compare two projects in Android studio

I have a couple Android Studio projects that are similar, and I want to know exactly where their source files differ. What is an easy way to do that?
John Surname
  • 357
  • 1
  • 4
  • 8