目录

Show 例子

以下是Erlang中可用的按位运算符。

Sr.No. 操作符和说明
1

band

这是按位“和”运算符

2

bor

这是按位“或”运算符

3

bxor

这是按位“xor”或Exclusive或运算符

4

bnot

这是按位否定运算符

以下是展示这些运算符的真值表 -

p q p&q p | q p ^ q
00000
01011
11110
10011

以下代码段显示了如何使用各种运算符。

例子 (Example)

-module(helloworld). 
-export([start/0]). 
start() -> 
   io:fwrite("~w~n",[00111100 band 00001101]), 
   io:fwrite("~w~n",[00111100 bxor 00111100]), 
   io:fwrite("~w~n",[bnot 00111100]), 
   io:fwrite("~w~n",[00111100 bor 00111100]).

上述计划的输出将是 -

输出 (Output)

76
0
-111101
111100
↑回到顶部↑
WIKI教程 @2018