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版)
36
|
第
2
章
头文件
inttypes.h
包含了头文件
stdint.h
和一些其他特性,例如为了满足
printf()
和
scanf()
函
数的调用需求而扩展的整数类型(请参见第
16
章)。
2.3 浮点类型
C
语言也包含多种特殊的算术类型,它们用来表示具有小数点的非整数。用于实数计算
的标准浮点类型(
floating-point
)包括:
float
用于单精度的变量。
double
用于双精度的变量。
long double
用于扩展精度的变量。
浮点数值只能以有限的精度被存储,这取决于该数值的二进制表示方式以及用于存储该
数值的内存空间大小。精度采用有效数字的个数表示。例如,“
6
位十进制数的精度”
或“
6
位精度”表示该类型的二进制表示方式可以存储
6
位的十进制实数,因此当它被转
换回
6
位十进制数时,其值等于原来的
6
位实数。小数点的位置不影响结果,其前面的
0
和后面的
0
都不算在这
6
个数字中。
123456000
和
0.00123456
都可以存储在
6
位精度的类
型中。
在
C
语言中,对浮点数据进行算术运算,通常需要采用
double
或者更高精度的类型。实
现版本所采用的浮点精度由头文件
float.h
中定义的宏
FLT_EVAL_METHOD
指定。例如,如果
宏
FLT_EVAL_METHOD
值为
1
,则下面的乘法运算采用
double
类型:
float height = 1.2345, width = 2.3456; // float
变量具有单精度
double area = height * width
;
//
实际计算采用双精度
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