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

9183 questions
2238
votes
40 answers

Compare two dates with JavaScript

Can someone suggest a way to compare the values of two dates greater than, less than, and not in the past using JavaScript? The values will be coming from text boxes.
Alex
  • 33,445
  • 21
  • 43
  • 41
671
votes
20 answers

How do I check for null values in JavaScript?

How can I check for null values in JavaScript? I wrote the code below but it didn't work. if (pass == null || cpass == null || email == null || cemail == null || user == null) { alert("fill all columns"); return false; } And…
Mahdi_Nine
  • 11,985
  • 25
  • 78
  • 112
460
votes
19 answers

Compare two files in Visual Studio

I saw new comparsion tool in VS 2012 for comparing two files or two versions of file. I like it. But when I tried to find it I can't because I don't use TFS. Is there a way how I can just compare two files with the built-in feature in VS (but…
Libor Zapletal
  • 12,142
  • 18
  • 79
  • 165
422
votes
10 answers

Comparing the contents of two files in Sublime Text

I have two cloned repositories of two very similar open-source projects, which I have been working on in different instances in Sublime Text 2 to arrive at my desired result. Code from both of these projects was used. I have been using Git as…
LanceLafontaine
  • 4,910
  • 3
  • 17
  • 33
350
votes
14 answers

Why does (0 < 5 < 3) return true?

I was playing around in jsfiddle.net and I'm curious as to why this returns true? if(0 < 5 < 3) { alert("True"); } So does this: if(0 < 5 < 2) { alert("True"); } But this doesn't: if(0 < 5 < 1) { alert("True"); } Is this quirk ever…
punkrockbuddyholly
  • 9,077
  • 7
  • 33
  • 60
277
votes
21 answers

Generic deep diff between two objects

I have two objects: oldObj and newObj. The data in oldObj was used to populate a form and newObj is the result of the user changing data in this form and submitting it. Both objects are deep, ie. they have properties that are objects or arrays of…
Martin Jespersen
  • 23,663
  • 6
  • 52
  • 66
275
votes
7 answers

Compare if BigDecimal is greater than zero

How can I compare if BigDecimal value is greater than zero?
Santhosh
  • 16,978
  • 21
  • 60
  • 74
220
votes
17 answers

Easiest way to compare arrays in C#

In Java, Arrays.equals() allows to easily compare the content of two basic arrays (overloads are available for all the basic types). Is there such a thing in C#? Is there any "magic" way of comparing the content of two arrays in C#?
user356178
216
votes
15 answers

How to compare binary files to check if they are the same?

What is the easiest way (using a graphical tool or command line on Ubuntu Linux) to know if two binary files are the same or not (except for the time stamps)? I do not need to actually extract the difference. I just need to know whether they are the…
sawa
  • 156,411
  • 36
  • 254
  • 350
207
votes
15 answers

What is best tool to compare two SQL Server databases (schema and data)?

I would like to compare two SQL Server databases including schema (table structure) and data in tables too. What is best tool to do this?
Tomasz Smykowski
  • 24,175
  • 51
  • 149
  • 222
192
votes
19 answers

How to compare two colors for similarity/difference

I want to design a program that can help me assess between 5 pre-defined colors which one is more similar to a variable color, and with what percentage. The thing is that I don't know how to do that manually step by step. So it is even more…
Ana Fernandes
  • 1,921
  • 2
  • 12
  • 4
184
votes
14 answers

How to compare type of an object in Python?

Basically I want to do this: obj = 'str' type ( obj ) == string I tried: type ( obj ) == type ( string ) and it didn't work. Also, what about the other types? For example, I couldn't replicate NoneType.
Joan Venge
  • 269,545
  • 201
  • 440
  • 653
181
votes
14 answers

Compare two data.frames to find the rows in data.frame 1 that are not present in data.frame 2

I have the following 2 data.frames: a1 <- data.frame(a = 1:5, b=letters[1:5]) a2 <- data.frame(a = 1:3, b=letters[1:3]) I want to find the row a1 has that a2 doesn't. Is there a built in function for this type of operation? (p.s: I did write a…
Tal Galili
  • 22,529
  • 40
  • 118
  • 179
180
votes
9 answers

What is the difference between == and Equals() for primitives in C#?

Consider this code: int age = 25; short newAge = 25; Console.WriteLine(age == newAge);  //true Console.WriteLine(newAge.Equals(age)); //false Console.ReadLine(); Both int and short are primitive types, but a comparison with == returns true and a…
Mohammad Zargarani
  • 1,402
  • 2
  • 12
  • 19
155
votes
6 answers

Tool for comparing 2 binary files in Windows

I need a tool to compare 2 binaries. The files are quite large. Some freeware or trial tools I found on the Internet are not convenient to use for large files. Can you recommend me some tools?
mustafa
  • 3,174
  • 7
  • 29
  • 52
1
2 3
99 100