Operators

// -Operators can be roughly classified into three categories:
// -Unary — Act on single operands
// -Binary — Act on two operands
// -Ternary — Act on three operands

Mathematical Operators

// Simple Mathematical Operators
// OPERATOR CATEGORY EXAMPLE EXPRESSION    RESULT
//    +     Binary   var1 = var2 + var3;   var1 is assigned the value that is the sum of var2 and var3.
//    -     Binary   var1 = var2 - var3;   var1 is assigned the value that is the value of var3 subtracted from the value of var2.
//    *     Binary   var1 = var2 * var3;   var1 is assigned the value that is the product of var2 and var3.
//    /     Binary   var1 = var2 / var3;   var1 is assigned the value that is the result of dividing var2 by var3.
//    %     Binary   var1 = var2 % var3;   var1 is assigned the value that is the remainder when var2 is divided by var3.
//    +     Unary    var1 = +var2;         var1 is assigned the value of var2.
//    -     Unary    var1 = -var2;         var1 is assigned the value of var2 multiplied by -1.
//
//
// Increment and Decrement Operators
// OPERATOR CATEGORY EXAMPLE EXPRESSION RESULT
//   ++     Unary    var1 = ++var2;     var1 is assigned the value of var2 + 1. var2 is incremented by 1.
//   --     Unary    var1 = --var2;     var1 is assigned the value of var2 - 1. var2 is decremented by 1.
//   ++     Unary    var1 = var2++;     var1 is assigned the value of var2. var2 is incremented by 1.
//   --     Unary    var1 = var2--;     var1 is assigned the value of var2. var2 is decremented by 1.
//
//
// ++ always results in its operand being incremented by one.
// −− always results in its operand being decremented by one.
//
// Placing one of these operators before its operand means that
// the operand is affected before any other computation takes place. Placing it after the operand means that the
// operand is affected after all other computation of the expression is completed.

 1 class MainClass
 2 {
 3     static void Main()
 4     {
 5         double x;
 6         x = 1.5;
 7         Console.WriteLine(++x);
 8         x = 1.5;
 9         Console.WriteLine(x++);
10         Console.WriteLine(x);
11     }
12 }
13
14 Output
15 2.5
16 1.5
17 2.5

Assignment Operators

// Like =, they all result in a value being assigned to the variable on their left side based on the operands and operators on their right side.
//
// OPERATOR CATEGORY EXAMPLE EXPRESSION RESULT
//   =      Binary   var1 = var2;       var1 is assigned the value of var2.
//   +=     Binary   var1 += var2;      var1 is assigned the value that is the sum of var1 and var2.
//   -=     Binary   var1 -= var2;      var1 is assigned the value that is the value of var2 subtracted from the value of var1.
//   *=     Binary   var1 *= var2;      var1 is assigned the value that is the product of var1 and var2.
//   /=     Binary   var1 /= var2;      var1 is assigned the value that is the result of dividing var1 by var2.
//   %=     Binary   var1 %= var2;      var1 is assigned the value that is the remainder when var1 is divided by var2.

Operator Precedence

// PRECEDENCE     OPERATORS
// Highest        ++, -- (used as prefi xes); +, - (unary)
//                 *, /, %
//                 +, -
//                 =, *=, /=, %=, +=, -=
// Lowest         ++, -- (used as suffixes)

时间: 2024-11-09 02:41:28

Operators的相关文章

VHDL之concurrent之operators

Using operators Operators can be used to implement any combinational circuit. However, as will become apparent later, complex circuits are usually easier to write using sequential code, even if the circuit does not contain sequential logic. Example M

<Effective C++>读书笔记--Ctors、Dtors and Assignment Operators

<Item 5> Know what functions C++ silently writes and calls 1.If you don't declare them yourself, compilers will declare their own versions of a copy constructor, a copy assignment operator, and a destructor. Furthermore, if you declare no constructo

Java文法(8)—Separators 和 Operators

-------------------------------------------------------------------------------------------------------------------- 扩展一(Separators): ----------------------------------------------------------------------------------------------------------------- 说明

Paper Reading: Beyond Correlation Filters: Learning Continuous Convolution Operators for Visual Tracking

Beyond Correlation Filters: Learning Continuous Convolution Operators for Visual TrackingECCV 2016  The key point of KCF is the ability to efficiently exploit available negative data by including all shifted versions of a training sample, in anthor w

【LeetCode】282. Expression Add Operators

题目: Given a string that contains only digits 0-9 and a target value, return all possibilities to add binary operators (not unary) +, -, or * between the digits so they evaluate to the target value. Examples: "123", 6 -> ["1+2+3", &q

Thinking in Java,Fourth Edition(Java 编程思想,第四版)学习笔记四)之Operators

At the lowest level, data in Java is manipulated using operators Using Java Operators An operator takes one or more argument and produces a new value. The arguements are in a different form than ordinary method calls, but the effect is the same. + :

[string]Expression Add Operators

Total Accepted: 5561 Total Submissions: 26048 Difficulty: Hard Given a string that contains only digits 0-9 and a target value, return all possibilities to add binary operators (not unary) +, -, or * between the digits so they evaluate to the target

Expression Add Operators

Given a string that contains only digits 0-9 and a target value, return all possibilities to add binary operators (not unary) +, -, or *between the digits so they evaluate to the target value. Examples: "123", 6 -> ["1+2+3", "1

[LeetCode][JavaScript]Expression Add Operators

Expression Add Operators Given a string that contains only digits 0-9 and a target value, return all possibilities to add binary operators (not unary) +, -, or * between the digits so they evaluate to the target value. Examples: "123", 6 -> [

[LeetCode] Expression Add Operators 表达式增加操作符

Given a string that contains only digits 0-9 and a target value, return all possibilities to add operators +, -, or * between the digits so they evaluate to the target value. Examples: "123", 6 -> ["1+2+3", "1*2*3"] "