Most voted "comparison" questions
Used to compare different types (compare variables, objects, files, etc).
Learn more…155 questions
Sort by count of
-
29
votes2
answers463
viewsWhat’s a loose comparison?
In the documentation of PHP, on the switch says: Note: Note that the switch/case does loose comparison. What is a loose comparison? And what is the difference between a loose comparison and a rigid…
-
26
votes3
answers10445
viewsReact Native or Ionic?
I need to create an App and would like to know which of your technologies is the most suitable for mobile development today. What is the main difference between Reactnative and Ionic? Which of the…
-
24
votes5
answers20688
viewsHow to verify similarity between strings?
It’s very common to compare strings, which is usually done by comparing equality. However, today I have arisen the need to compare the likeness between two strings, so I can compare how similar they…
-
23
votes3
answers59486
viewsHow to compare dates in PHP?
I would like to know which function I use to compare two dates and return to larger. I have a form for HR registration in which the user will register their professional experiences and the date of…
-
22
votes2
answers8927
viewsIn Python, what is the difference between == and the is command?
I’m confused in the use of two commands, the is and the == that as far as I understood they perform the same thing that is to compare if two objects are equal. Is there any more performatic?…
-
12
votes4
answers316
viewsIs it bad practice to make this comparison?
To compare two values with a single one, I can do as in the example: if(foo == "abc" || foo == "54") { ... } But as I need to add more conditions, it starts to get complicated: if(foo == "abc" ||…
-
10
votes4
answers236
viewsComparison syntax referring to the same variable
Let me give you an example in C#: namespace Compare { class Program { static void Main(string[] args) { string name = "Girl"; if(name == "Girl" || == "girl") //... } } } This form clearly contains…
-
8
votes2
answers1484
viewsCompareto: Comparison method violates its general Contract!
I found many questions on this subject, and tried all the suggestions I found, however the problem persisted. If anyone can help me, there’s my problem: I have a list of requests, this list is…
-
8
votes3
answers446
viewsCould someone explain to me the term "Specification Pattern", applied in Javascript?
I did some research on the net, I found this website with valuable information. I work a lot with conditionals using javascript, see an excerpt of my function that receives radiogroup as a parameter…
-
8
votes1
answer428
viewsWhat are the differences between the methods "equals()", "compareTo()", and even "=="?
I am aware that there are differences between comparing objects using equals(), compareTo() and even the operator ==, but in detail what are the differences between them and the care we should take…
-
7
votes1
answer107
viewsCompare Strings by format not by value
I have a shape of a String, for example: xxxx-xxxx-xxx But instead of the x can enter several letters or numbers, example: A216-0450-013 X2LP-1018-589 Y585-0000-047 What I need to do is compare to…
-
6
votes1
answer7278
viewsHow to use the function toupper() in char in C?
I’m creating a variable: char nome[20]; After this, I am asking the user to enter a name: printf("Digite um nome : "); scanf("%20s",&nome); And I’m checking to see if the name is correct:…
-
6
votes1
answer35
viewsNumber of queries in a dataframe
I have a data frame where in each column is the value of events in the period, I need to calculate the increment and the decrease of these periods for a larger basis and I could not do: p1<-…
-
5
votes2
answers4659
viewsComparing only the Datetime field date in C#
I only need to compare the date of two fields DateTime. DateTime aux = new DateTime(2016, 09, 02, 10, 0, 0); if (aux.Equals(DateTime.Now)) { //Alguma ação... } In the code above, I need you to enter…
-
5
votes2
answers1763
viewsComparing user typed variable with file variable
Inside of my file arquivo.txt I keep two strings "nome" and "senha", They lay one on the other. I need to take the name and password entered by the user and compare it with the name and password I…
-
5
votes1
answer426
viewsWarning compared between floats how to proceed
In an exercise I did, you are asked to make a compound interest calculation with for for the values of 5%, 6%, 7%, 8%, 9%, and 10%. As I could not use a check per counter being the counter a type…
-
5
votes1
answer264
viewsIs it possible to compare numerical values in strings without casting to Number type?
I have two numeric values that are recovered in strings and I wonder if there is a way to compare them to see which numerical value is higher, but without having to keep converting to type Number…
-
5
votes2
answers1728
viewsHow to receive a string and switch to check in C?
I have to develop an algorithm that gets the name of a place, for example, "School", and based on this, do a check of the string in the switch, and if it is "School", then it sends a message to the…
-
5
votes1
answer298
viewsCompare objects in R
I have two dataframes: atualizada PIMPF_Br_A_1_sa PIMPF_Br_A_2_sa 1995-01-01 74.35501 35.59109 1995-02-01 74.06131 35.43400 1995-03-01 74.06131 35.93259 and: atualizada PIMPF_Br_A_1_sa…
-
5
votes2
answers1699
viewsHow to compare each character of a Java String?
I’m creating a Java application where I travel through one String with a bow for and I need to check every character of that String. Example: for (int i = 0; i < texto.length(); i++) { char…
-
4
votes2
answers178
viewsHow do I get the values of a date in the "dd/MM/yyyy hh:mm" format and compare it to the system date after setting it in this same format?
I wanted to make a comparison between the date contained in the hora1 object and the system date, as I can do? import java.text.SimpleDateFormat; import java.util.Date; public class MainTarefas {…
-
4
votes2
answers1261
viewsCompare value at each String position in Java?
I’m having trouble comparing a value in each position of a String, follows the example below: parametro = "30,60,90"; private int countVirgulas(String parametro) { int count = 0; for (int i = 0; i…
-
4
votes1
answer206
viewsComparing Columns in SQL Server
Good afternoon! I wonder if you can help me. I am with the following case, we have a client who is with the version of our system VERY outdated, with this is missing several columns in the SQL…
-
4
votes3
answers1831
viewsHow to compare variables using Javascript?
I use a lot of variable comparison. Example: if (item[l].item[0] == 'tipoRescisao') { log.info('Tipo Rescisão: ' + item[l].item[1]) if ( (item[l].item[1] == (1)) || (item[l].item[1] == 01) ||…
-
4
votes2
answers855
viewsMake comparison using String.Contains() disregarding Casing
I need to check if a given term exists within a string (in SQL is something like like '%termo%'). The point is, I need this done without considering Casing of the two strings. How can I do that?…
c# string comparison case-insensitive cash-sensitivityasked 7 years, 10 months ago Jéf Bueno 67,331 -
4
votes1
answer1323
viewsMake comparison using String.Contains() disregarding accents and case
I need to check how to make a comparison between strings, in C#, using the method Contains() that so disregards the sensitivity of accents and marry of a string. Example: var mainStr = "Acentuação";…
-
4
votes3
answers1175
viewsUsing Double in the compareTo method
I’m having a doubt. I have several methods of comparison, however, one of the attributes used to make the comparison is double. Then an error occurs: Cannot invoke compareTo(double) on the Primitive…
-
4
votes1
answer1072
viewsChar comparison, ignoring the case sensitive
The proposal is to create a program that compares n first positions of the two vectors and returns saying whether or not they are equal. So far so good, but I do not know how to ignore the case…
-
4
votes2
answers914
viewsHow does larger and smaller Javascript string checking work?
If you perform the condition '15000' > '100000' the result will be true If you perform the condition 15000 > 100000 the result will be false If you perform the condition '15000' > '200000'…
-
4
votes4
answers806
viewsAssignment of Java Arrays
I have two String Arrays and I have to compare them. After the comparison I must assign the repeated values in another Array. My problem is that I wish to assign only the Strings repeated without…
-
4
votes1
answer397
viewsJava Priorityqueue Comparator
I’m trying to understand why the native mode of java is not performing the comparison, I don’t know where I’m going wrong. MAIN // EXERCICIO PARA COMPARAR DOIS OBJETOS, USANDO CLASSE NATIVA DE…
-
4
votes1
answer203
viewsFunction "strcmp()" working without adding "string. h"
I wrote an algorithm in C that uses the function strcmp(). Even forgetting to add the string.h the algorithm worked. I would like to understand how it worked since I only found this function in the…
-
4
votes1
answer84
viewsEntry problem in loop comparing string
I can’t make it into the loop using only the char 'Anunciar', when you put something in, it starts the loop. What should I do? #include <stdio.h> #include <stdlib.h> #include…
-
4
votes2
answers98
viewsHow do I know if a value is higher or lower than another value in a list using recursion?
Being a classified monster with your name, attack and defense. ("medusa", 2, 5) or (string, int, int). And getting a list of monsters, how do I create a function that tells me if the monster I want…
-
3
votes2
answers2857
viewsCompare 2 Matrices and Return a Third (R)
The following matrices being Matrix(A) [,1] [,2] [,3] [,4] [,5] [1,] 0.228 0.285 0.285 0.285 0.380 [2,] 0.228 0.285 0.570 0.380 0.228 [3,] 0.380 0.285 0.228 0.380 0.285 [4,] 0.285 0.285 0.570 0.380…
-
3
votes2
answers5037
viewsSort a list of objects by more than one attribute
How to sort a list of objects by more than one attribute? First is made the ordering of the score, then as tiebreaker criteria we have the winning number and then the goal balance. Something like…
-
3
votes1
answer350
viewsThread in Java and Nodejs
We know that benchmarks are specific measures and do not count for all cases, certainly what and how you measure matters a lot, so I will try to be very specific. In the case of a server having…
-
3
votes1
answer611
viewsProblem comparing strings and string being broken into two python lines
I was creating a game that scrambles words, and the user has 6 attempts to guess what the word is. I’ll put the code here: import random def main(): while True: input('Presisone enter para sortear…
-
3
votes1
answer36
viewsWhy does "is" not work when comparing the replace of a string?
I tried to do in CLI Python 2.7.6 the following command: 'foo bar'.replace(" ", "") is 'foobar' But returned False Despite 'foo bar'.replace(" ", "") return 'foobar' Does anyone have any logical…
-
3
votes3
answers531
viewsString.equals and Nullpointerexception method
Although the doubt is very basic, I would like to understand why the equals in this case: String texto = null; System.out.println("teste".equals(texto)); Returns false normally (example in ideone),…
-
3
votes1
answer40
viewshow to fix this error ? Exp: 125 < 55
how to correct this error ? insert firstNumber = 125 , and secondNumber = 055 the result : 125 > 055 if firstNumber = 125 and secondNumber = 55 result : 125 < 55 book code: Javascriptme pag 23…
-
3
votes1
answer1434
viewsHow to compare two shades of color and give the percentage of similarity (Java)?
How to take images with the same dimensions (images of two equal squares) and analyze their tones to tell how similar they are (return a percentage of the similarity between the two tones of the…
-
3
votes2
answers767
viewsCompare String Elements in C
I would like to separate a word and compare each element of the string with a letter, I tried to make this comparison using the strcmp() but when executed seems to ignore it, or does not perform.…
-
3
votes2
answers866
viewsCompare using String.Contains() disregarding accents and case
I know there’s already question, I even used the same title to call attention, but this one refers to C#, I’m having this problem in java, code: //historico e searchC são ArrayLists, no caso do case…
-
3
votes1
answer158
viewsFind differences between arrays, with probability of variation
Good afternoon guys, I’m reading about the numpy library setdiff1d function (https://docs.scipy.org/doc/numpy/reference/generated/numpy.setdiff1d.html). It basically serves to express the different…
-
3
votes2
answers100
viewsProblem with Javascript date comparison
I have a Javascript function that is to check if the "current data_is" is larger than "data_validity". If larger, it is to display on the screen the "Expired" text, if not, keep the "Valid" text".…
-
2
votes2
answers104
viewsHow to check with binary operations?
I have an application in which I separate the mistakes by crease, for example, system errors of 10-19, ie 10 slots for system errors, then have 20-29 login errors, etc. How can I make one if to know…
-
2
votes1
answer218
viewsError comparing two strings
I’m trying to compare two strings, when I enter a name in my chained list it cannot be entered if it already exists. I have used the function searchname to display a searched name and to delete, but…
-
2
votes1
answer519
viewsCompare lines with txt Java Android
I would like to create a method that compares each line of my text view with each line of a txt file here I go through the txt file for example, in my text view are displayed the words blue green…
-
2
votes3
answers12149
viewsHow to check if a number is within a range in Python?
In Python, I would like to check if a number is within a range. There is a more pythonic way than the following code? if n >= 100 and n <= 200: ...