The result of x & y is true if both x and y evaluate to true. The & operator computes the logical AND of its operands. That is, it produces true, if the operand evaluates to false, and false, if the operand evaluates to true. The unary prefix ! operator computes the logical negation of its operand. Those operators evaluate the right-hand operand only if it's necessary. Binary & (conditional logical AND) and || (conditional logical OR) operators.Those operators always evaluate both operands. Binary & (logical AND), | (logical OR), and ^ (logical exclusive OR) operators.The following operators perform logical operations with bool operands: The >= operator returns true if its left-hand operand is greater than or equal to its right-hand operand, false otherwise. Debug.Log(8.0 > 6.1) // output: Trueĭebug.Log(double.NaN > 6.1) // output: Falseĭebug.Log(double.NaN 6.1) // output: False The > operator returns true if its left-hand operand is greater than its right-hand operand, false otherwise. Less than operator = 6.1) // output: False Those operators are supported by all integral and floating-point numeric types. The (greater than), = (greater than or equal) comparison, also known as relational, operators compare their operands. You can also use the - operator for delegate removal. The subtraction operator - subtracts its right-hand operand from its left-hand operand. You can also use the + operator for string concatenation and delegate combination. The addition operator + computes the sum of its operands. For the decimal operands, the remainder operator % is equivalent to the remainder operator of the System.Decimal type.For the operands of integer types, the result of a % b is the value produced by a - (a / b) * b.The remainder operator % computes the remainder after dividing its left-hand operand by its right-hand operand. You must explicitly convert the float or double operand to the decimal type. If one of the operands is decimal, another operand can be neither float nor double, because neither float nor double is implicitly convertible to decimal. The division operator / divides its left-hand operand by its right-hand operand. The multiplication operator * computes the multiplied product of its operands: Debug.Log(6 * 3) // output: 18 Debug.Log(+5) // output: 5ĭebug.Log(b.GetType()) // output: System.Int64 The unary + operator returns the value of its operand and the unary - operator computes the numeric negation of its operand. The result of -x is the value of x after the operation, as the following example shows: It can also be added before or after a value: The result of x- is the value of x before the operation, as the following example shows: The "subtract one" operator is the opposite of ++ (-= 1), meaning it subtracts one integer from a numeric value. The result of ++x is the value of x after the operation, as the following example shows: This operator can be added either before the value or after the value, which would result in a different behavior: //The result of x++ is the value of x before the operation, as the following example shows: The "add one" operator (or ++) means += 1, in other words, it's a quick way to add one integer to a numeric value, without having to type extra code.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |