Erlang operators (comparison operators, numeric operators, shift operators, logical operators) _php tips

Source: Internet
Author: User
Tags integer division logical operators
comparison operator for Erlang

opdescription== equals/= not equal to =< less than equal to < less than >= greater than or equal > greater than =:= exact equals =/= exact difference equal to and exact equals:
If you want to compare two numbers, if two numbers are different types, such as float and int, then the = = Operation First converts two numbers to the same type. Example:

1> 1==1.0.
True
2> 1=:=1.0.
False

So the general recommendation is to use precision equals 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 number division, the result is a floating-point number numberbnot the unary not operator Integerdiv integer division, The result is an integer integerrem Yushu integerbandand Operation Integerboror Operation Integerbxorxor XOR operations INTEGERBSL left shift operation INTEGERBSR right shift operation Integer
logical operators

Opdescriptionnot logic Notand Logical Andor Logic Orxor logical XOR Atom True and false to represent logical "true" and "false"
In addition, the logical operators also include a OrElse and AndAlso

The original OR and and is operated without a "short-circuit operation", while the OrElse and AndAlso are operated with short-circuit operations.

Short Circuit Operation Example

Express1 and Express2

Express1 AndAlso Express2

If Express1 is false, and will continue to judge the Express2, and then the overall judgment is false, and andalso "short-circuit" operation, directly determine the entire expression is false, in terms of efficiency, AndAlso will be higher

Copy Code code as follows:

Op Description
= = equals
/= is not equal to
=< less than or equal
< less than
>= is greater than or equal to
> Greater than
=:= exactly equal to
=/= accurate is not equal to

Examples
Copy Code code as follows:

> 1==1.0.
True
> 1=:=1.0.
False
> 1 > A.
False

Note: The average language is less than or equal to "<=" and Erlang's "=<" writes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.