Erlang operators (comparison operators, numerical operators, shift operators, logical operators)_PHP tutorial

WBOY
Release: 2016-07-21 15:17:05
Original
1381 people have browsed it

Erlang's comparison operators

opDescription==equal/=not equal==greater than or equal>greater than=:=exact equal=/=exact not equal to equal and The difference between exact equality:
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

Copy code The code is as follows:

op Description
== Equal to
/= Not equal to
=< Less than or equal to
< Less than
>= Greater than or equal to
> ; Greater than
=:= Exactly equal to
=/= Exactly not equal to

Examples
Copy code The code is as follows:

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

Note: Less than or equal to in general language is "<=" while "=<" in erlang is written like this

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/325803.htmlTechArticleErlang comparison operator opDescription==equal/=not equal=less than equal to less than=greater than equal to greater than=:= Exact equal =/= The difference between exact not equal and exact equal: If you want to compare...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!