tagged [operators]

What does the "&=" in this C# code do?

What does the "&=" in this C# code do? I came across some code that looks like this: Why would I use the bitwise operator instead of "="?

29 Dec at 16:56

What's the difference between “mod” and “remainder”?

What's the difference between “mod” and “remainder”? My friend said that there are differences between "mod" and "remainder". If so, what are those differences in C and C++? Does '%' mean either "mod"...

1 Jul at 11:54

Why is x++-+-++x legal but x+++-+++x isn't?

Why is x++-+-++x legal but x+++-+++x isn't? I'm wondering why in C# the following is fine: But Isn't? Why is there a bias against the +?

11 Jul at 17:33

What is the difference between '/' and '//' when used for division?

What is the difference between '/' and '//' when used for division? Is there a benefit to using one over the other? In Python 2, they both seem to return the same results:

What are true and false operators in C#?

What are true and false operators in C#? What is the purpose and effect of the `true` and `false` in C#? The [official documentation](http://msdn.microsoft.com/en-us/library/eahhcxk2(VS.71).aspx) on t...

26 Mar at 16:20

Is there a conditional ternary operator in VB.NET?

Is there a conditional ternary operator in VB.NET? In Perl (and other languages) a conditional ternary operator can be expressed like this: Is there a similar operator in VB.NET?

throwing an exception if an object is null

throwing an exception if an object is null I've recently discovered that: can be rewritten as Can the following be rewritten in a similar fashion?

18 Feb at 01:25

How do I get a decimal value when using the division operator in Python?

How do I get a decimal value when using the division operator in Python? For example, the standard division symbol '/' rounds to zero: However, I want it to return 0.04. What do I use?

Batch not-equal (inequality) operator

Batch not-equal (inequality) operator According to [this](http://tldp.org/LDP/abs/html/dosbatch.html), `!==!` is the not-equal string operator. Trying it, I get: What am I doing wrong?

18 Sep at 18:30

programmatically specify operator

programmatically specify operator Is it possible to specify an operator `R` where `R` can be an arithmetic, relational or logical operator ? For example a function that calculates where I can specify ...

9 May at 19:41

Use of "instanceof" in Java

Use of "instanceof" in Java > [What is the 'instanceof' operator used for?](https://stackoverflow.com/questions/7313559/what-is-the-instanceof-operator-used-for) I learned that Java has the `instance...

22 Jul at 14:59

IS NOT operator in C#

IS NOT operator in C# I can't find the "is not" operator in C#. For example I have the code below which does not work. I need to check that `err` is not of type class `ThreadAbortException`.

18 Jan at 17:19

What do two left angle brackets mean?

What do two left angle brackets mean? I saw a loop which I've never seen before: ``` for (int i = 0; i

== vs Equals in C#

== vs Equals in C# What is the difference between the evaluation of == and Equals in C#? For Ex, but Edited:

19 Mar at 14:47

Why does negating a value change the result when XORing it with 1?

Why does negating a value change the result when XORing it with 1? I know the working of XOR, results to but how does this return 2?

Why are there no ||= or &&= operators in C#?

Why are there no ||= or &&= operators in C#? We have equivalent assignment operators for all Logical operators, Shift operators, Additive operators and all Multiplicative operators. Why did the logica...

What are the | and ^ operators used for?

What are the | and ^ operators used for? > [What are bitwise operators?](https://stackoverflow.com/questions/276706/what-are-bitwise-operators) Recently I came across a few samples that used the | a...

23 May at 12:23

C# Nullable Equality Operations, Why does null <= null resolve as false?

C# Nullable Equality Operations, Why does null = null null == null ``` resolves as true? In other words, why isn't `null >= null` equivalent to `null > null || null == null`? Does anyone have the offi...

30 Mar at 15:16

How to call custom operator with Reflection

How to call custom operator with Reflection In my small project I'm using `System.Reflection` classes to produce executable code. I need to call the `+` operator of a custom type. Does anybody know ho...

Using the && operator in an if statement

Using the && operator in an if statement I have three variables: How to use and (`&&`) operator in if statement like this: When I write this code it gives error. What is the right way?

24 Mar at 18:38

What is the difference between the | and || or operators?

What is the difference between the | and || or operators? I have always used `||` (two pipes) in OR expressions, both in C# and PHP. Occasionally I see a single pipe used: `|`. What is the difference ...

23 Jul at 08:5

How to use greater than operator with date?

How to use greater than operator with date? No idea what is going on here. Here is the query, right from phpMyAdmin: ``` SELECT * FROM `la_schedule` WHERE 'start_date' >'2012-11-18'; ``` But I consist...

15 Jan at 06:28

Why nullable int (int?) doesn't increase the value via "+=" if the value is NULL?

Why nullable int (int?) doesn't increase the value via "+=" if the value is NULL? I have a page counter type of int?: It works ONLY if the value of ViewCount property is (any int). Why the compiler do...

No increment operator (++) in Ruby?

No increment operator (++) in Ruby? > [Why doesn't Ruby support i++ or i— for fixnum?](https://stackoverflow.com/questions/3660563/why-doesnt-ruby-support-i-or-i-for-fixnum) Why is there no incremen...

23 May at 11:54

How to check if the string is empty?

How to check if the string is empty? Does Python have something like an empty string variable where you can do: Regardless, what's the most elegant way to check for empty string values? I find hard co...

^=, -= and += symbols in Python

^=, -= and += symbols in Python I am quite experienced with Python, but recently, when I was looking at the solutions for the [codility](https://www.codility.com/) sample tests I encountered the opera...

4 Jun at 19:2

What is the !! (not not) operator in JavaScript?

What is the !! (not not) operator in JavaScript? I saw some code that seems to use an operator I don't recognize, in the form of two exclamation points, like so: `!!`. Can someone please tell me what ...

13 Aug at 21:20

What does ?? operator means in C#?

What does ?? operator means in C#? > [What do two question marks together mean in C#?](https://stackoverflow.com/questions/446835/what-do-two-question-marks-together-mean-in-c) Hi, I was looking for...

23 May at 12:25

Operator '??' cannot be applied to operands of type 'string' and 'System.DBNull'

Operator '??' cannot be applied to operands of type 'string' and 'System.DBNull' I have the following C# code: But it throws the following compilation error: > Operator `??` cannot be applied to opera...

23 Jun at 04:15

What does "|=" mean? (pipe equal operator)

What does "|=" mean? (pipe equal operator) I tried searching using Google Search and Stack Overflow, but it didn't show up any results. I have seen this in opensource library code: What does "|=" ( `p...

13 Jan at 19:58

What is the "??" operator for?

What is the "??" operator for? I was wondering about `??` signs in `C#` code. What is it for? And how can I use it? What about `int?`? Is it a nullable int? ### See also: > [?? Null Coalescing Operato...

What does the ^ operator do in Java?

What does the ^ operator do in Java? What function does the `^` (caret) operator serve in Java? When I try this: ...it gives me: > for n = 5, returns 0 for n = 4, returns 1 for n = 6, returns 3 ......

28 Feb at 03:6

What does the colon (:) operator do?

What does the colon (:) operator do? Apparently a colon is used in multiple ways in Java. Would anyone mind explaining what it does? For instance here: ``` String cardString = ""; for (PlayingCard c :...

19 Jan at 15:15

Detecting negative numbers

Detecting negative numbers I was wondering if there is any way to detect if a number is negative in PHP? I have the following code: I need to find out if `$profitloss` is negative and if it is, I need...

26 Sep at 20:26

C# what does the == operator do in detail?

C# what does the == operator do in detail? in c# what does exactly happen in the background when you do a comparison with the "==" operator on two objects? does it just compare the addresses? or does ...

8 Apr at 02:58

Handlebarsjs check if a string is equal to a value

Handlebarsjs check if a string is equal to a value Is it possible in Handlebars to check if a string is equal to another value without registering a helper? I can't seem to find anything relevant to t...

C# NOT (~) bit wise operator returns negative values

C# NOT (~) bit wise operator returns negative values Why does C#'s bitwise `NOT` operator return `(the_number*-1)-1`? How would I do this in C#?

17 Jun at 12:32

What does question mark and dot operator ?. mean in C# 6.0?

What does question mark and dot operator ?. mean in C# 6.0? With C# 6.0 in the VS2015 preview we have a new operator, `?.`, which can be used like this: What exactly does it do?

31 Oct at 20:52

C# bitwise shift on ushort (UInt16)

C# bitwise shift on ushort (UInt16) I need to perform a bitwise left shift on a 16-bit integer (ushort / UInt16), but the bitwise operators in C# seem to apply to int (32-bit) only. How can I use

VB.NET vs C# integer division

VB.NET vs C# integer division Anyone care to explain why these two pieces of code exhibit different results? VB.NET v4.0 C# v4.0

17 May at 04:16

If the left operand to the ?? operator is not null, does the right operand get evaluated?

If the left operand to the ?? operator is not null, does the right operand get evaluated? I'm looking at using the `??` operator (null-coalescing operator) in C#. But the [documentation](http://msdn.m...

4 Oct at 16:9

Convert to binary and keep leading zeros

Convert to binary and keep leading zeros I'm trying to convert an integer to binary using the bin() function in Python. However, it always removes the leading zeros, which I actually need, such that t...

Is BitArray faster in C# for getting a bit value than a simple conjuction with bitwise shift?

Is BitArray faster in C# for getting a bit value than a simple conjuction with bitwise shift? 1). `var bitValue = (byteValue & (1

SQL Logic Operator Precedence: And and Or

SQL Logic Operator Precedence: And and Or Are the two statements below equivalent? and Is there some sort of truth table I could use to verify this?

Is it possible to create a new operator in c#?

Is it possible to create a new operator in c#? I know you can overload an existing operator. I want to know if it is possible to create a new operator. Here's my scenario. I want this: ``` var x = (y

24 Jun at 18:32

Short circuiting statement evaluation -- is this guaranteed? [C#]

Short circuiting statement evaluation -- is this guaranteed? [C#] Quick question here about short-circuiting statements in C#. With an if statement like this: Is it guaranteed that evaluation will sto...

Is there a "null coalescing" operator in JavaScript?

Is there a "null coalescing" operator in JavaScript? Is there a null coalescing operator in Javascript? For example, in C#, I can do this: The best approximation I can figure out for Javascript is usi...

7 Apr at 01:9

Store an operator in a variable

Store an operator in a variable Is there a way to store an operator inside a variable? I want to do something like this (pseudo code): ``` void MyLoop(int start, int finish, operator op) { for(var i...

10 Jan at 23:16