Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use the operator of Erlang

Shulou Source: shulou.com Published: 2022-06-01 06:18:35 09月18日 Update

This article is about how to use the operator of Erlang. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Comparison operator of Erlang

OpDescription== equals / = not equal to = greater than =: = exact equal to = / = the difference between precise non-equal and exact equal:

If you want to compare two numbers, if there are different types between them, such as float and int, the = = operation will first convert the two numbers to the same type. For example:

1 > 1. 0.

True

2 > 1. 0.

False

Therefore, it is generally recommended that accuracy equals to comparison

Compare the size level of the 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 numberbnot unary not operator integerdiv integer division, the result is integer integerrem to Yushu 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 atom 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 did not have a "short circuit" operation, while orelse and andalso had a short circuit operation.

Examples of short circuit operation

Express1 and Express2

Express1 andalso Express2

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

The copy code is as follows:

Op Description

= = equal to

/ = not equal to

=

< 小于等于 < 小于 >

= greater than or equal to

> greater than

=: = exactly equal to

= / = accurate is not equal to

Examples

The copy code is as follows:

> 1. 0. 0.

True

> 1. 1. 0. 0.

False

> 1 > a.

False

Note: the general language is less than or equal to "

Tags: Operations operators logic precision code two same content integers more points articles types results division different good original practical between Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Shulou Information OPPO Reno Microsoft Huawei