Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the operator of Erlang

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

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 "

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 299

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report