Erlang operator of comparison operator numeric operator shift operator logical operator

  • 2020-05-19 04:21:23
  • OfStack

The comparison operator for Erlang

opDescription== equal to /= not equal to = < Less than or equal to < Less than > Is greater than or equal to > The difference between being equal to and being equal to:
If you want to compare two Numbers, if there are different types between two Numbers, such as float and int, then the == operation will first convert the two Numbers to the same type. For example:

1 > 1==1.0.
true
2 > 1=:=1.0.
false

So it is generally recommended to use the exact equivalent to compare

The size level of the 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, the result is floating point numberbnot1 bit not operator integerdiv integer division, the result is the integer integerrem yushu integerbandand operation integerboror operation integerbxorxor xor operation integerbsl left shift operation integerbsr right shift operation integer
Logical operator

opDescriptionnot1 meta-logic notand logic andor logic xor atomic true and false represent the "true" and "false" of logic
In addition, the logical operators include an orelse and an andalso

The original or and and are operated without short circuit operations, while orelse and andalso are operated with short circuit operations.

Examples of short circuit operation

Express1 and Express2

Express1 andalso Express2

If Express1 is false, and will continue to judge Express2, and then judge it as false as a whole, while andalso "short circuit" operation will directly judge the entire expression as false. In terms of efficiency, andalso will be 1 higher

 
op Description 
==  Is equal to the  
/=  Is not equal to  
=<  Less than or equal to  
<  Less than  
>=  Greater than or equal to  
>  Is greater than  
=:=  Exact equal to  
=/=  Exact is not equal to  

Examples
 
> 1==1.0. 
true 
> 1=:=1.0. 
false 
> 1 > a. 
false 

Note: 1 general language is less than or equal to" < =" and erlang "= < "This write

Related articles: