Erlang operators (comparison operators, numerical operators, shift operators, logical operators ). Erlang comparison operator opDescription equals not equal to less than or equal to greater than: exact equals exact not equal to or equal to the exact difference: if you want to compare Erlang comparison operators
OpDescription = equal to/= not equal to = <小于等于<小于> = Greater than or equal to> greater than =: = exact equals =/= exact not equal to or exact equals:
To compare two numbers, if they are of different types, such as float and int, the = operation first converts the two numbers to the same type. Example:
1> 1 = 1.0.
True
2> 1 =: = 1.0.
False
Therefore, we recommend that you use exact equals to decomparison.
Comparison operator size level:
Number <atom <reference <fun <port <pid <tuple <list <bit string
3> 1>.
False
OpDescriptionArgument type +
Number-
Number +
Number-
Number *
Number/floating-point division, the result is the floating-point numberbnot unary not operator integerp integer division, the result is the integer integerrem to calculate the Yushu integerbandand operation the integerboror operation the integerbxorxor operation the integerbsl left shift operation
Logical operators
OpDescriptionnot mona1 logic notand logic andor logic orxor logic xor atom true and false indicate logical "true" and "false"
In addition, the logical operators include orelse and andalso
The original or and operations do not contain short-circuit operations, while orelse and andalso operations do not.
Example of short circuit operation
Express1 and Express2
Express1 andalso Express2
If Express1 is false, and will continue to judge Express2, then the overall determination is false, and andalso "short circuit" operation, directly determine the entire expression is false, in terms of efficiency, andalso will be higher
The code is as follows:
Op Description
= Equal
/= Not equal
= <Less than or equal
<Less
> = Greater than or equal
> Greater
=: = Exact equals
= // = Exact not equal
Examples
The code is as follows:
> 1 = 1.0.
True
> 1 =: = 1.0.
False
> 1>.
False
Note: Generally, the language is less than or equal to "<=" and erlang's "= <" is written in this way.
OpDescription = equal to/= not equal to = less than or equal to = greater than =: = precise equal to =/= exact not equal to or equal to the exact same: if you want to compare...