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版)
44
|
第
3
章
更大的类型。在这种情况下,编译器会按照类型层次自动选择第一个范围足够表示该值
的类型。对于十进制常量来说,类型层次为:
int, long, long long
对于八进制和十六进制常量来说,类型层次为:
int, unsigned int, long, unsigned long, long long, unsigned long long
例如,在一个
16
位系统中,十进制常量
50000
的类型是
long
,因为
int
类型的最大值是
32 767
,即
2
15
-
1
。
也可以利用后缀来显式地定义常量的类型。如果常量具有后缀
l
或
L
,
其类型就是
long
(在
必要情况下,还可以为一个范围更大的类型,这个“更大”对应于前面提到的类型层
次)。类似地,如果后缀是
ll
或
LL
,那么类型至少为
long long
。后缀
u
或
U
用于指明常
量是无符号类型。
long
后缀与无符号后缀可以混合使用。表
3-1
列出了一些例子。
表3-1:具有后缀的常量示例
整数常量 类型
0x200 int
512U unsigned int
0L long
0Xf0fUL unsigned long
0777LL long long
0xAAAllu unsigned long long
3.2 浮点常量
浮点常量可采用十进制或者十六进制记数法。下面两个小节会分别讨论这两种记数法。
3.2.1 十进制浮点常量
普通浮点常量包含一个十进制数字序列和一个小数点。也可以把这个值乘以
10
的某个次
方,如同科学记数法(
scientific notation ...
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