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版)
314
|
第
17
章
同的
pragma
命令”,或者“包含此
pragma
的语句块”才终止。在语句块结束的地方,编
译器的行为会恢复到以前“在语句块开始时”的状态。
17.2.5 浮点环境
浮点环境包含针对浮点状态标记的系统变量以及控制模式。当浮点异常发生时,例如零
作为除数,则状态标记就会被设定。控制模式是指程序能够设定的浮点算术行为,例
如,结果要如何取近似值以获得到可表示的值。编译器对于浮点异常和控制模式的支持
都是可选的。
凡是涉及访问浮点环境的声明都被包含在头文件
fenv.h
中(请参见第
16
章)。
程序如果需要访问浮点环境,应在访问前使用下面标准
pragma
来通知编译器:
#pragma STDC FENV_ACCESS ON
这个命令可以避免编译器进行优化操作,例如,改变表达式的计算次序,因为优化操作
可能会干扰状态标记的查询或控制模式的应用。
FENV_ACCESS
的应用方法与
FP_CONTRACT
、
CX_LIMITED_RANGE
一样:在所有函数的外
面,或在语句块里(请参考前一节的内容)。这由编译器自行决定,把
FENV_ACCESS
的
默认值设置为
ON
或
OFF
。
访问状态标记
使用表
17-9
中的函数可以访问异常状态标记。这些函数中的一个参数是用来指示等待处
理的异常类别。下面的整数宏被定义在头文件
fenv.h
中,用来指示单独的异常类型:
FE_DIVBYZERO FE_INEXACT FE_INVALID FE_OVERFLOW FE_UNDERFLOW
仅当实现版本支持某个异常时,其对应的宏才会被定义。宏 ...
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