Questions tagged [equality]

Equality is a relationship between two or more items or variables or objects that exists if (1) the items are the same item, variable, or object or (2) the items are different items, variables or objects but they have the same value. This tag should generally be used with programming language specific tags as well as other contextual tags such as database system. The post should include as much context about the equality test as is possible.

This tag is typically used for questions concerning how to determine if two objects or variables are either the same object or different objects with the same value. Questions almost always require a programming language tag and other tags for context.

Programming languages represent variables, objects, or other storage containers using different underlying mechanisms for the storage of the values of variables and objects. A test for equality is to compare some characteristic of two variables or objects to determine if the characteristic is the same.

This characteristic is typically either (1) the storage identifier such as a reference handle, memory address, etc. when checking if the two are the same object or (2) the characteristic is the value of the objects retrieved using a storage identifier when checking if the value of the two are the same value.

Different programming languages and different operating environments have differences in how equality is tested and what operators are used to express a test for equality. In some cases various conversions from underlying storage representations may be involved in testing for equality.

See What is the difference between equality and equivalence? as well as Equivalence relation and natural ordering on a class in Java

2095 questions
0
votes
4 answers

Comparing 2 Integers in C++

I get an error when I try to compare two integers in Qt. if ((modus==2) & (move != -1)) error: invalid operands of types '' and 'int' to binary 'operator!=' Do I need other operators? I have googled but it…
buddy
  • 821
  • 2
  • 12
  • 30
0
votes
1 answer

Determine how List.Except() is comparing items

I have read about Except here. I am still a bit confused. I am using .NET 4.8. I have 7 different implementations of my custom interface IMyInterface. All these implementations are held in a List or IEnumerable. I am doing the following in many…
Eric Snyder
  • 1,816
  • 3
  • 22
  • 46
0
votes
6 answers

How do I search for one array whose contents match another?

I have an ArrayList of int arrays that is returning false when I ask if it contains the specified coordinates. It does contain the coordinates I request so it should return TRUE. Here's my code. //debug code for (int i = 0; i <…
WildBamaBoy
  • 2,663
  • 6
  • 25
  • 23
0
votes
4 answers

How to check if a value is equal to exactly one value from an array

I have the following array: const person = [ { name: "John", surname: "Doe" }, { name: "Jane", surname: "Williams" }]; I want to check if a match is equal to just one name from the array. I did the following: match === person[0].name ||…
0
votes
2 answers

PHP - why equal string are not equal with NumberFormatter

Why are below code echos not equal even if both strings are equal? $number = 1234567.89; $expected = 'GBP 1,234,567.89'; $fmt = new NumberFormatter('en_AU@currency=GBP', NumberFormatter::CURRENCY); $currency = $fmt->formatCurrency($number,…
Chirag Kalani
  • 368
  • 2
  • 9
0
votes
0 answers

(wx)Maxima: what are the best practices for using `equal` with floats?

I am working with data that has the following form: /* initial value */ xi:-8$ /* intermediate value */ a:-0.2$ /* final value */ xf:8$ /* step size */ dx:0.1$ /* first list of values */ x1:makelist(i,i, xi, a, dx)$ /* second list…
Rax Adaam
  • 790
  • 3
  • 11
0
votes
0 answers

How do I avoid having two objects actually being the same (having equal memory address)?

I have created a Node class which takes the a value (int) in the constructor. It also can store another Node as 'next'. I have found out that when I create a Node like this: public void methodSignature(int value) {Node node = new Node(value);} in a…
Kristina
  • 97
  • 1
  • 8
0
votes
1 answer

Unable to compare types of identical but redeclared namedtuples in Python

While working on a difference engine to identify differences in very large data structures, I noticed that a type comparison between identical-but-redeclared namedtuples misbehaves. Redeclaring the namedtuples is unavoidable*. Here is a minimal…
Drakes
  • 23,254
  • 3
  • 51
  • 94
0
votes
1 answer

Why does my wildcard search with SUMIF not work?

In MS Excel, I'm trying to make a wildcard search using the SUMIF function. I'm following this guide. However, for some reason my Excel doesn't think the words in the range are equal to the criterion. Suppose I have the following data: I have apple…
Sam
  • 305
  • 1
  • 8
0
votes
1 answer

Numeric promotion and equality?

Possible Duplicate: Wrapper class and == operator I have a puzzle from my friend. Here is it: public class Test{ public static void main(String[] args){ Integer i = 1000; //10 Integer y = 1000; //10 …
Hung Tran
  • 1,595
  • 2
  • 17
  • 17
0
votes
1 answer

How to implement a for loop inside a for loop inside a for loop?

I have two variables (n;p) in two independent equations, one to find C and the other to find T. For the first iteration I assume the values of n and p finding C and T, now I have to find all the pairs of n and p that will make C=T. Additionally to…
greenrabbit
  • 99
  • 1
  • 10
0
votes
1 answer

Create a variable that classifies observations in groups of observations defined by equality conditions of values for other variables

I have struggled with this question for a long time, and I have looked extensively on the Internet but never found a solution. Imagine I have the following dataset: df <- data.frame("Individuals" = c(1,2,3,4,5,6), "Height" =…
0
votes
0 answers

Since we have operator<=> in C++20, is operator== still needed?

I'm in the process of learning how comparisons work in C++20 and I'm struggling to understand one thing: since operator<=> has to check for equality do we really need a separate operator==? For example, the following check: a == b could be…
rubix_addict
  • 1,811
  • 13
  • 27
0
votes
1 answer

CSS Grid - equal height of table-alike grandchild cells in visually synced rows

Is there a way to automatically keep in sync rows height of table-alike structure between headers and body? I mean to force CSS Grid to keep each header and data row to have equal height, despite them having separate parents? I don't want headers…
ScriptyChris
  • 639
  • 4
  • 16
  • 48
0
votes
1 answer

Wrong comparison result for equal values in python

def fib_gen(fib=-1): print(f"initial fib={fib}") a = 1 b = 0 yield b i = 1 print(f"initial i={i}") while(i!=fib):#infinite sequence by default, since default value of fib is -1 c = a a = a+b b = c i = i+1 print(f"i={i}") …
Robert Page
  • 366
  • 4
  • 10
1 2 3
99
100