Home >Backend Development >PHP Tutorial >Erlang operators (comparison operators, numerical operators, shift operators, logical operators)_PHP tutorial
Erlang's comparison operators
opDescription==equal/=not equal=
If you want to compare two numbers, if the two numbers are of different types, such as float and int, then the == operation will first convert the two numbers into the same type. Example:
1> 1==1.0.
true
2> 1=:=1.0.
false
So it is generally recommended to use exact equals to compare
Size level of comparison operator:
number < atom < reference < fun < port < pid < tuple < list < bit string
3> ; 1 > a.
false
opDescriptionArgument type+
number-
number+
number-
number*
number/Floating point division, result Is a floating point number numberbnot unary not operator integerdiv integer division, the result is an integer integerrem integerbandand operation integerboror operation integerbxorxor XOR operation integerbsl left shift operation integerbsr right shift operation integer
logical operator
opDescriptionnot Unary logic notand logic andor logic orxor logic xor atoms true and false represent logical "true" and "false"
In addition, the logical operators also include an orelse and andalso
The original or and and are not With "short-circuit operation" operation, orelse and andalso have short-circuit operation operation.
Example of short-circuit operation
Express1 and Express2
Express1 and also Express2
If Express1 is false, and will continue to judge Express2, and then the overall judgment is false. The andalso "short circuit" operation directly determines that the entire expression is false. In terms of efficiency, andalso will be higher