Skip to Content
C语言核心技术(原书第2版)
book

C语言核心技术(原书第2版)

by Peter Prinz, Tony Crawford
August 2017
Intermediate to advanced
798 pages
17h 44m
Chinese
China Machine Press
Content preview from C语言核心技术(原书第2版)
表达式和运算符
|
85
表达式
和运算符
有效位(
least significant bit
)。例如,考虑字符值
'*'
,它的
ASCII
编码为
42
,相当于二
进制的
101010
:
位模式 0 0 1 0 1 0 1 0
位位置 7 6 5 4 3 2 1 0
在本例中,值
101010
被表示成一个
8
位的字节内容,因此前面多两个
0
。
5.2.6.1 布尔位运算符
表
5-11
中列举的运算符可以对操作数的每个位进行布尔运算。这种二元运算符把两个不
同操作数内相同位置的位关联起来。被设定的位(也就是值为
1
的位)被解释为
true
,
被清除的位(也就是值为
0
的位)被解释为
false
。
除布尔运算符
AND
、
OR
和
NOT
以外,也有位异或运算符(
exclusive-OR
,
XOR
)。这
些都在表
5-11
进行了列举。
表5-11:布尔位运算符
运算符 意义 示例 对于每个位位置的结果(1=设定,0=清除)
&
位AND
x & y
如果
x
和
y
都为1
,
则得到1
;
如果
x
或
y
任何一个为
0
,
或都为0
,
则得到0
|
位OR
x | y
如果
x
或
y
为1
,
或都为1
,
则得到1
;
如果
x
和
y
都为
0
,
则得到0
^
位XOR
x ^ y
如果
x
或
y
的值不同
,
则得到1
;
如果两个值相同
,
则得到0
~
位NOT
(
1的补码
)
~x
如果
x
为0
,
则得到1
;
如果
x
是1
,
则得到0
位运算符的操作数必须是整数类型,并且遵循寻常算术转换(
usual arithmetic
conversion
)。转换后获得的操作数通用类型就是整个计算结果的类型。表 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

算法精讲视频课程:24篇系列讲座

算法精讲视频课程:24篇系列讲座

罗伯特·塞奇威克, 凯文·韦恩(Kevin Wayne)

Publisher Resources

ISBN: 9787111562207