Questions tagged [comparison-operators]

Comparison operators, as their name implies, allow to compare two values and usually return Boolean value (true or false).

658 questions
-2
votes
1 answer

Numerical issues in R

It is a well known fact that when comparing two real numbers it is always better to work with a small tolerance to avoid numerical issues. I am looking for an example where when we compare a number x having d number of decimal places returns FALSE…
S.Perera
  • 688
  • 2
  • 7
  • 19
-2
votes
1 answer

String Comparison in C++ with IF Statements?

I'm very new to C++, just started learning using an online course about 30 minutes ago. I'm a little confused as to why this string comparison isn't working in a basic math script: #include #include using namespace std; int…
APixel Visuals
  • 975
  • 2
  • 13
  • 29
-2
votes
3 answers

Sort array of numbers with arithmetic operators vs comparison operators

In Javascript there's two solutions to write the sort() function to sort an array of numbers in ascending order. var numbers = [2, 10, 2, 6, 4]; // first solution numbers.sort((a, b) => a - b); // [2, 2, 4, 6, 10] // second…
Huy Tran
  • 1,237
  • 2
  • 13
  • 32
-2
votes
2 answers

What is the // comparator in ruby? Does it exist

I am new to Ruby and using codecademy to start my learning. I am on the topic of comparators / relational operators and have been given an example with // as a comparator. Am i reading what codecademy is asking me wrong? Because I can't find…
-2
votes
3 answers

C++ comparison of integers with float

I have the following code.that demonstrates the problem I am having. How come the comparison is not evaluating to true? Is this a limitation of integer and floating point comparisons? #include int main(){ double m = -0.625; …
Belphegor
  • 1,326
  • 2
  • 14
  • 28
-2
votes
1 answer

Avoidance of less-than-or-equal-to operator in java.lang.Character

In Character.java of the java.lang package (Oracle JDK 8), public static final int MIN_SUPPLEMENTARY_CODE_POINT = 0x010000; public static final int MAX_CODE_POINT = 0X10FFFF; public static boolean isSupplementaryCodePoint(int codePoint) { …
Mac
  • 240
  • 1
  • 5
-2
votes
3 answers

How can I compare multiple variables in C?

How can I compare multiple variables to see if they all are the same? (e.g a==b==c) I know that you can do if (a==b) && (a==c) && (b==c) {} but with many variables (in my case 9) that's not a good way to do it. EDIT: I don't need every variable…
JohnGRThess
  • 31
  • 1
  • 4
-2
votes
1 answer

How to display error from comparison statement

I am trying to get in error message to pop when certain conditions do not match. The information is browsing through a csv file. My issue is one of my statements work but does not display anything. Here is my condition statement. $spellingerror =…
ShanayL
  • 1,147
  • 13
  • 27
-3
votes
2 answers

Python3 comparison operators

Python 3 does not support comparison between different data types. 1 < '1' will execute with: `TypeError: '<' not supported between instances of 'float' and 'str'` But why does 1 == '1' (or something like 156 == ['foo']) returns False?
Elantonio
  • 1
  • 1
-3
votes
1 answer

How to return all facts that are less than or equal to an input value in prolog

I'm new to Prolog and am struggling with this problem. I have a list of authors, books, and…
user13591163
-3
votes
3 answers

Why doesn’t Python provide default implementations of __le__ and __ge__?

The following mathematical relationships between comparison relations (=, ≠, <, >, ≤ and ≥) are always valid and therefore implemented by default in Python (except for the 2 union relationships, which seems arbitrary and is the reason of this…
Maggyero
  • 3,120
  • 2
  • 24
  • 43
-3
votes
1 answer

Confusion regarding comparison operators in std::min, std::max

std::min and std::max allows custom comparators, but I am a bit confused on how the ordering works. Consider the following: int i = 1; int j = 2; auto min_val = min(i, j, [](const auto val1, const auto val2){ if(val1 < val2) return…
anonuser01
  • 1,307
  • 7
  • 14
-3
votes
3 answers

Comparison sign 'greater than' and 'equal to' in CASE SQL Statement

I am new to SQL Server and this is my first post. I am getting the message "incorrect syntax near '=' when using the Case Statement. Here is an example of my code: Select * , CASE when a > b THEN b = a when c > d THEN d = c when e >…
MsAB2
  • 1
  • 1
  • 3
-3
votes
1 answer

comparing two unequal tuples and finding which is greater and smaller

I am working on the following python code and the output is not up to my expectation. I am comparing corresponding values using lexicographical method to find out which tuple is greater which i think is used in tuple comparisons and i donot think…
-3
votes
1 answer

java.util.Scanner.nextInt(Unknown Source) failing

I have been trying to get an integer array and it keeps failing. I am trying to find the missing element in an array. Here is my code. What am I doing wrong here? import java.util.Scanner; public class GFG { public static void main(String[]…
Raneesh
  • 29
  • 8
1 2 3
43
44