# Operators are

used to perform mathematical or logical operations while the program is running. The

built-in operators in the Z1h language are:-arithmetic

operators -relational operators -logical operators -bitwise operators -assignment operators -other operators

Next Let's take a detailed look at the introduction of each operator.

## Arithmetic Operators The

following table lists all arithmetic operators in Z1h language. Assume that A value is 10 and B value is 20.

Operator | Description | Example |
---|---|---|

+ | Add | A + B output result 30 |

- | Subtraction | A-B output result-10 |

\ * | Multiplication | A * B output result 200 |

/ | Division | B / A output result 2 |

% | Find the remainder | B% A output result 0 |

++ | self-increment | A ++ output result 11 |

- | self-decrease | A– Output result 9 |

\ * \ * | Power operation | A * B Output 10 to the 20th power result 100000000000000000000 |

## Relational operators The

following table lists all relational operators in Z1h language. Assume that the value of A is 10, B The value is 20.

Operator | Description | Example |
---|---|---|

== | Check whether two values are equal, return True if equal, otherwise return False | (A == B) Is False |

! = | Check whether the two values are not equal, return True if not equal, otherwise return False | (A! = B) is True |

> | Check whether the left value is greater than the right value, if it returns True, otherwise return False | (A> B) is False |

< | Check whether the left value is less than the right value, if it returns True, otherwise return False | (A ) is True |

> = | Check whether the left value is greater than or equal to the right value, if Yes returns True otherwise False | (A> = B) is False |

<= | Checks whether the left value is less than or equal to the right value, if it returns True otherwise returns False | (A <= B) is True |

## logical operation The

following table lists all logical operators in the Z1h language. Assume that A is True and B is False.

Operator | Description | Example |
---|---|---|

&& | Logical AND operator. If both operands are True, the condition is True, otherwise False | (A && B) is False |

! | Logical NOT operator. If the condition is True, then the logical NOT condition is False, otherwise True | ! (A && B) is True |

## bit operators

Bitwise operators Integers in the memory bit operation.

The following table lists the bit operators &, |, and ^ is calculated:

p | q | p & q | p | q | p ^ q |
---|---|---|---|---|

0 | 0 | 0 | 0 | 0 |

0 | 1 | 0 | 1 | 1 |

1 | 1 | 1 | 1 | 0 |

1 | 0 | 0 | 1 | 1 |

Assuming A = 60; B = 13; its binary number is converted to:

```
A = 0011 1100
B = 0000 1101
-----------------
A & B = 0000 1100
A | B = 0011 1101
A ^ B = 0011 0001
```

supported bit operators As shown in the following table. Suppose A is 60 and B is 13:

Operator | Description | Example |
---|---|---|

& | The bitwise AND operator "&" is a binary operation Operator. Its function is the binary phase and | (A & B) corresponding to the two numbers involved in the operation. The result is 12, the binary value is 0000 1100 |

The bitwise OR operator " | ||

^ | The bitwise XOR operator "^" is a binary operator. Its function is that the binary numbers corresponding to the two numbers involved in the operation are different or different. When the two corresponding binary values are different, the result is 1 | (A ^ B) The result is 49, the binary value is 0011 0001 |

<< | Left shift operator "<<" is a binocular operator. Shifting left by n bits means multiplying the power of 2 by 2. The function shifts all binary digits of the operand on the left of "<<" to the left by a few bits, the number of "<<" moves to the right the number of bits designated, discarding high, low up 0 | a << 2 result 240 binary 0000 to 1111 |

> > | right shift operator ">>" It is a binocular operator. Shifting n bits to the right is divided by 2 to the power of n. Its function is to shift all binary digits of the operand on the left side of ">>" to the right by a few bits, and the number on the right side of ">>" specifies the movement The number of digits | A >> 2 The result is 15 and the binary value is 0000 1111 |

## Assignment operators The

following table lists all assignment operators in Z1h language

Operator | Description | Example |
---|---|---|

= | Simple assignment operator, assign the value of an expression to an lvalue | C = A + B Assign the result of A + B expression to C |

+ = | Add after assigning | C + = A equals C = C + A |

-= | subtract after subtraction | C-= A equals C = C-A |

\ * = | multiply before assignment | C \ * = A equals C = C \ * A |

/ = | Divide and then assign | C / = A is equal to C = C / A |

% = | After the remainder and assign | C% = A is equal to C = C% A |

<< = | Assignment after left shift | C << = 2 Equal to C = C << 2 |

> > |

| ^ = | Assignment after bitwise XOR | C ^ = 2 is equal to C = C ^ 2 | | \ | = | Bitwise or after assignment | C \ | = 2 is equal to C = C \ | 2 |

## Ternary operator

Z1h supports both the ternary operator styles of `Java`

and`Python`

Operator | Style | Example |
---|---|---|

Judgment statement? Value when correct: wrong The value at the time | Java / JavaScript | print (4% 2 == 0? "A": "B") |

The value at the time of the correct if judgment value of the else error statement | Python | print ("AA" if 4% 2 = = 0 else "BB") |

## Other operators The

following table lists other operators in Z1h language

Operator | Description | Example |
---|---|---|

& | Return to variable storage Address | & a will give the actual address of the variable |

* | pointer variable | * a is a pointer variable |

## Operator Priority

Some operators have higher priority, the operation direction of the binary operator is from Left to right. The following table lists all operators and their priority, from top to bottom represents the priority from high to low

priority | operation type | associativity | operator |
---|---|---|---|

20 | parentheses | irrelevant | (…) |

19 | member access | from left to right | … …. |

to count member access | from left to right | ||

new (with parameter list) | n / a | new… (…) | |

Function call | From left to right | … (…) | |

Optional chaining | From left to right | ?. | |

18 | new (no parameter list) | From right to left | new… |

17 | postincrement (operator after) … ++ | ||

post-decrement (after operator) | … - - | ||

16 | logical NOT | from right to left | … |

Bitwise not | ~… | ||

Unary addition | +… | ||

Unary subtraction | -… | ||

Preceding increment | ++… | ||

Preceding decrement | -… | ||

typeof | typeof… | ||

void | void… | ||

delete | delete… | ||

await | await… | ||

15 | power | from right to left | … **… |

14 | Multiplication | From left to right | |

… *… | |||

Division | … /… | ||

Modulus | …%… | ||

13 | Addition | From left to right | |

… +… | |||

Subtraction | …-… | ||

12 | Shift left by bit | From left to right | … <<… |

Shift right by bit | … >>… | ||

Unsigned right shift | … >>>… | ||

11 | Less than | From left to right | … <… |

Less than or equal | … <=… | ||

Greater than ……>… | |||

Greater than or equal to | …> =… | ||

in | … in… | ||

instanceof | … instanceof… | ||

10 | equal sign | from left to right | |

… ==… | |||

not equal sign | …! =… | ||

equal sign | … ===… | ||

non-equal sign | …! ==… | ||

9 | bitwise and | from left to right | … &… |

8 | press Bit XOR | From left to right | … ^… |

7 | Bitwise OR | From left to right | … |

6 | Logical AND | Left to right | … &&… |

5 | Logical OR | From left to right | … |

4 | Condition operator | From right to left | …?…:… |

3 | Assignment | From right to left | … =… |

… + =… | |||

…-=… | |||

… * =… | |||

… / =… | |||

…% =… | |||

… << =… | |||

… >> =… | |||

… >>> = … | |||

… & =… | |||

… ^ =… | |||

… | =… | ||

2 | yield | From right to left | yield… |

yield * | yield *… | ||

1 | Expand operation Character | n / a | …… |

0 | Comma | From left to right | …,… |