cout.setf(ios::showpoint)和setprecision()
发布日期:2022-04-07 05:21:23
浏览次数:29
分类:技术文章
本文共 588 字,大约阅读时间需要 1 分钟。
#include <iomanip>为头文件。
cout.setf(ios::showpoint) 在c++中是为了保留原有的类型精度(四舍五入原则)。
比如,
#include#include using namespace std;int main(){ double a=3; //cout.setf(ios::showpoint); cout<
当我们加上 cout.setf(ios::showpoint)后,结果会保留原来的精度。
比如,
#include#include using namespace std;int main(){ double a=3; cout.setf(ios::showpoint); cout<
如果想在最大精度范围内自定义精度,可以用setprecision();它存在于#include <iomanip>头文件中,必须要。用法举例如下,
#include#include #include using namespace std;int main(){ double a=3; cout.setf(ios::showpoint); cout< <
转载地址:https://blog.csdn.net/weixin_62659979/article/details/123586495 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
不错!
[***.144.177.141]2024年03月27日 06时32分48秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
PHP Extension programming
2019-04-27
海量数据处理
2019-04-27
PHP防止注入攻击
2019-04-27
多路IO复用模型 select epoll 等
2019-04-27
Linux Epoll介绍和程序实例
2019-04-27
output_buffering详细介绍
2019-04-27
php缓冲 output_buffering和ob_start
2019-04-27
php error_reporting 详解
2019-04-27
剖析PHP中的输出缓冲
2019-04-27
HTTP响应头不缓存
2019-04-27
apache的keepalive和keepalivetimeout(apache优化)
2019-04-27
内容协商 (Content Negotiation)
2019-04-27
关于URL编码
2019-04-27
HTTP中的缓存
2019-04-27
Varnish 和 Squid比较到底强多少
2019-04-27
mysql常用语句集锦
2019-04-27
PHP的Smarty
2019-04-27
ecshop模板的原理分析
2019-04-27
深入探究Smarty模版
2019-04-27
PHP高效率写法(详解原因)
2019-04-27