官术网_书友最值得收藏!

Operands and operators

An operator is the part of an instruction that specifies the value to be operated on. An operator also carries out a specific operation on its operands. Examples of operators are +, -, *, /, and %. Operators can be categorized based on the type of operations carried out and the number of operands acted upon by the operator.

Based on the type of operations carried out by the operator, we can classify operators into:

  • Relational operators
  • Assignment operators
  • Logical operators
  • Arithmetic operators
  • Bitwise operators

Operator type

Examples

Relational operators

>, <, >=, <=, ==

Assignment operators

+=, -=, *=, /=, =

Logical operators

&&, ||, !

Arithmetic operators

+, -, *, /

Bitwise operators

and(bits), or(bits), xor(bits), inv(), shl(bits), shr(bits), ushr(bits)

 

Based on the number of operands acted upon, we have two main types of operators in Kotlin:

  • Unary operators
  • Binary operators

Operator type

Description

Examples

Unary operator

Requires only one operand

!, ++, - -

Binary operator

Requires two operands

+, -, *, /, %, &&, ||

主站蜘蛛池模板: 兴文县| 加查县| 武冈市| 忻州市| 建水县| 威海市| 略阳县| 固阳县| 息烽县| 迁西县| 申扎县| 牡丹江市| 濮阳县| 宣汉县| 安塞县| 定兴县| 富锦市| 香港 | 慈利县| 三都| 茂名市| 军事| 克拉玛依市| 原平市| 泸西县| 宜阳县| 高清| 惠东县| 本溪| 博罗县| 苏尼特左旗| 清苑县| 宁强县| 漳平市| 额济纳旗| 东丰县| 白水县| 内江市| 花莲县| 凌源市| 襄汾县|