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.
O’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
I 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
I’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
I'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.