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
34
votes
7 answers

Compare binary files in C#

I want to compare two binary files. One of them is already stored on the server with a pre-calculated CRC32 in the database from when I stored it originally. I know that if the CRC is different, then the files are definitely different. However, if…
Simon Farrow
  • 1,901
  • 2
  • 20
  • 26
34
votes
5 answers

How can I verify that an array of strings contain a certain string?

Given : String[] directions = {"UP","DOWN","RIGHT","LEFT","up","down","right","left"}; String input = "Up"; How can I verify that an input from stdin is within the directions array or not ? I can make a loop and check each item with input using…
JAN
  • 21,236
  • 66
  • 181
  • 318
34
votes
2 answers

Flyway and liquibase together?

I've looked at both Liquibase and Flyway individually and on an individual comparison alone, Liquibase seems like the better tool for our needs. Some sources mention using both Liquibase and Flyway together. Liquibase seems to have everything Flyway…
Slayer0248
  • 1,231
  • 3
  • 15
  • 26
34
votes
7 answers

Why is Erlang slower than Java on all these small math benchmarks?

While considering alternatives for Java for a distributed/concurrent/failover/scalable backend environment I discovered Erlang. I've spent some time on books and articles where nearly all of them (even Java addicted guys) says that Erlang is a…
yetanothercoder
  • 1,689
  • 4
  • 21
  • 43
33
votes
4 answers

When you call remove(object o) on an arraylist, how does it compare objects?

When you call remove(object o) on an arraylist in java, how does it compare the objects to find the correct one to remove? does it use the pointer? or does it compare the objects using the interface Comparable?
Thomas Winsnes
  • 1,961
  • 1
  • 13
  • 15
33
votes
8 answers

Compare structures of two databases?

I wanted to ask whether it is possible to compare the complete database structure of two huge databases. We have two databases, the one is a development database, the other a production database. I've sometimes forgotten to make changes in to the…
streetparade
  • 32,000
  • 37
  • 101
  • 123
32
votes
10 answers

Compare Date object with a TimeStamp in Java

When I test this code: java.util.Date date = new java.util.Date(); java.util.Date stamp = new java.sql.Timestamp(date.getTime()); assertTrue(date.equals(stamp)); assertTrue(date.compareTo(stamp) == 0); assertTrue(stamp.compareTo(date) ==…
Torres
  • 5,330
  • 4
  • 26
  • 26
32
votes
4 answers

Fast way to compare inputstreams

I have a problem, I need to compare two inputstreams fast. Today I have a function like this: private boolean isEqual(InputStream i1, InputStream i2) throws IOException { try { // do the compare while (true) { int fr…
dacwe
  • 43,066
  • 12
  • 116
  • 140
32
votes
8 answers

Compare RGB colors in c#

I'm trying to find a way to compare two colors to find out how much they are alike. I can't seem to find any resources about the subject so I'm hoping to get some pointers here. Idealy, I would like to get a score that tells how much they are alike.…
SaphuA
  • 3,092
  • 3
  • 39
  • 58
32
votes
4 answers

Compare files and return only the differences using Notepad++

Notepad++ has a Compare Plugin tool for comparing text files, which operates like this: Launch Notepad++ and open the two files you wish to run a comparison check on. Click the “Plugins” menu, Select “Compare” and click “Compare.” The plugin…
Ifedi Okonkwo
  • 3,406
  • 4
  • 33
  • 45
32
votes
3 answers

Comparing to null - !== vs != in JavaScript

Ok, so I installed Linter on my Sublime editor while working on my node.js app. One of the things that it caught said that I should always use !== to compare an object to null (I usually use != ). So I changed it...but then I noticed that the !==…
David
  • 2,173
  • 3
  • 25
  • 36
32
votes
5 answers

How to compare two java objects

I have two java objects that are instantiated from the same class. MyClass myClass1 = new MyClass(); MyClass myClass2 = new MyClass(); If I set both of their properties to the exact same values and then verify that they are the same if(myClass1 ==…
Roy Hinkley
  • 10,111
  • 21
  • 80
  • 120
31
votes
7 answers

Comparing folders and content with PowerShell

I have two different folders with xml files. One folder (folder2) contains updated and new xml files compared to the other (folder1). I need to know which files in folder2 are new/updated compared to folder1 and copy them to a third folder…
Keith
  • 1,959
  • 10
  • 35
  • 46
31
votes
3 answers

How should I compare Perl references?

I want to check if two references point to the same object. It seems I can simply use if ($ref1 == $ref2) { # cheap numeric compare of references print "refs 1 and 2 refer to the same thing\n"; } as mentioned in perlref, but I vaguely remember…
David B
  • 29,258
  • 50
  • 133
  • 186
31
votes
8 answers

comparing querysets in django TestCase

I have a very simple view as follows def simple_view(request): documents = request.user.document_set.all() return render(request, 'simple.html', {'documents': documents}) To test the above view in my test case i have the following method…
Amyth
  • 32,527
  • 26
  • 93
  • 135