Skip to main content

Questions tagged [operators]

Operators are symbols that occur in nearly all programming and coding languages, used for performing calculations, comparisons, and assignments of data. Use this tag for any questions relating to operators, in any language, including things such as syntax, behaviour and use.

14 votes
15 answers
87k views

How to find the numbers in the thousands, hundreds, tens, and ones place in PYTHON for an input number? For example: 256 has 6 ones, 5 tens, etc

num = int(input("Please give me a number: ")) print(num) thou = int((num // 1000)) print(thou) hun = int((num // 100)) print(hun) ten =int((num // 10)) print(ten) one = int((num // 1)) print(one) I ...
53 votes
4 answers
35k views

What does |> (pipe greater than) mean in R?

I have recently come across the code |> in R. It is a vertical line character (pipe) followed by a greater than symbol. Here is an example: mtcars |> head() What is the |> code doing?
27 votes
1 answer
15k views

Scala - Booleans - & vs. &&, | vs. ||

I just noticed that in Scala Boolean supports both & and &&. Is there a difference between these two operators? The Scala docs use the exact same description for both of them, so I wasn't ...
302 votes
6 answers
159k views

insert vs emplace vs operator[] in c++ map

I'm using maps for the first time and I realized that there are many ways to insert an element. You can use emplace(), operator[] or insert(), plus variants like using value_type or make_pair. While ...
77 votes
11 answers
95k views

Difference between IN and ANY operators in SQL

What is the difference between IN and ANY operators in SQL?
-5 votes
1 answer
64 views

Comparison Operators result in Python

Why in Python print(bool(7>8)==False==True) results False, logically it should be True? as bool(7>8) is False, therefore False==False==True -> True==True -> True (NOT False) as the ...
0 votes
1 answer
19 views

Why does the PHP spread operator in an Elasticsearch query return different results than hardcoding parts of the query?

I've got a problem that I'm not entirely sure I understand. I've got the following Elasticsearch query, written in PHP, with fuzziness matching hardcoded; this results in about an expected 1,500 ...
-1 votes
2 answers
802 views

What is the difference between the operator acting elementwise vs on the matrix using Numpy?

Numpy docs talks about the difference between the product operator and the matrix operator. Unlike in many matrix languages, the product operator * operates elementwise in NumPy arrays. The matrix ...
0 votes
4 answers
16k views

Using multiple conditions in where clause of SQL Server

I have a table called finalres in my database which has list of statuses and accounts. I want to pull the accounts where the status should not be in: (xxx, ina, nfc) Also I want to pull the ...
-1 votes
2 answers
9k views

The python <- operator: what does it mean?

I am going through a Python/Pygame tutorial. I came across this <- operator. What does it mean? Here's the line of code: if bullet[1]<-64 or bullet[1]>640 or bullet[2]<-64 or bullet[...
1 vote
3 answers
2k views

How do you read the name of the ~/ operator in Dart

Dart has an integer division operator that looks like this: ~/ final x = 22 ~/ 7; // 3 The docs show it here, but they don't say what it is called. Am I using the correct name to call it an "...
0 votes
0 answers
53 views

What does a caret and an equal sign (^=) do in Python? [duplicate]

I was looking at the solution to a Python problem, and in it was int ^= num I don't understand what it means. When I searched for it, I got a bunch of posts explaining what the caret sign does on its ...
176 votes
5 answers
143k views

What does the caret (^) operator do?

I ran across the caret operator in python today and trying it out, I got the following output: >>> 8^3 11 >>> 8^4 12 >>> 8^1 9 >>> 8^0 8 >>> 7^1 6 >>...
2470 votes
10 answers
1.0m views

What are the basic rules and idioms for operator overloading?

Note: This question and the original answers are from 2010 and partially outdated. Most of it is still good and helpful, but the original text no longer covers everything there is to know about C++ ...
0 votes
1 answer
59 views

How to Implement operator-> for a Custom UniquePtr Class in C++? [duplicate]

I am trying to write my own implementation of unique_ptr in C++, and here is my UniquePtr header file: #include <iostream> template <typename T> class UniquePtr { T* ptr; public: ...

15 30 50 per page
1
2 3 4 5
522