std :: stringstream中双输出的默认格式标志(和宽度)是什么? [英] What are the default Format Flags (and widths) for double output in a std::stringstream?

查看:447
本文介绍了std :: stringstream中双输出的默认格式标志(和宽度)是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我将stringstream写入双精度时,默认格式是什么?

What is the default format, when I'm writting a double to a stringstream?

double v = 3.0;
std::stringstream ss;
ss << v;

在哪里可以找到stringstream的默认格式设置的列表?对于std::istream的所有派生类(在stdlib中),默认格式是否相同?

Where can I find a list of the default format setup for a stringstream? Is the default format the same for all derived classes of std::istream (within the stdlib)?

推荐答案

默认设置由 std::basic_ios::init ,并且对于从ios_base派生的所有流都相同.默认值为:

The defaults are setup by std::basic_ios::init and are the same for all streams derived from ios_base. The defaults are:

rdbuf()         sb
tie()           0
rdstate()       goodbit if sb is not a null pointer, otherwise badbit.
exceptions()    goodbit
flags()         skipws | dec
width()         0
precision()     6
fill()          widen(’ ’)
getloc()        a copy of the value returned by locale()
iarray          a null pointer
parray          a null pointer

因此默认精度为6

这篇关于std :: stringstream中双输出的默认格式标志(和宽度)是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆