Skip to Content
C++程序设计:原理与实践(基础篇)(原书第2版)
book

C++程序设计:原理与实践(基础篇)(原书第2版)

by 本贾尼 斯特劳斯特鲁普
August 2021
Intermediate to advanced
450 pages
9h 36m
Chinese
Pearson
Content preview from C++程序设计:原理与实践(基础篇)(原书第2版)

11.2.3 输出浮点数

如果你直接面对硬件的话,需要使用十六进制(或者八进制)的表示方式。类似地,如果你进行科学计算,就必须处理浮点数的格式。这些类型的处理与整型值的处理方法类似,都是借助于iostream的操纵符。例如:

会输出:

操纵符fixed、scientific和defaultfloat用来选择浮点数格式。defaultfloat是默认格式(也叫作通用格式(general format))。现在,我们可以这样写:

会输出:

对基本的浮点数格式化输出操纵符总结如下:

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.
Start your free trial

You might also like

C++语言导学(原书第2版)

C++语言导学(原书第2版)

本贾尼 斯特劳斯特鲁普
管理Kubernetes

管理Kubernetes

Brendan Burns, Craig Tracey
Go程序设计语言

Go程序设计语言

艾伦A. A.多诺万, 布莱恩W. 柯尼汉

Publisher Resources

ISBN: 9787111562252