ostringstream截断问题

ostringstream截断问题

本文介绍了ostringstream截断问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用ostringstream将float/double值转换为字符串

ostringstream ostr;
浮点m = 6.9293f;

ostr<< m;

它可以很好地处理这些值:),但是当我尝试给像3.0f这样的浮点后的值赋值为0时,它只是将值截断为3:confused :.
我不希望这件事发生,我想得到它的原色...:((

i am trying to convert the float/double values to the string using the ostringstream

ostringstream ostr;
float m = 6.9293f;

ostr<<m;

it is working fine with these values :) but when i tried to give values having 0 after floating point like 3.0f it simply truncate the value to 3:confused:.
i dont want this thing to happen i want to get the walues as it is... :((

推荐答案

tush_2003写道:
tush_2003 wrote:

感谢即时答复,但我已经做了所有这些事情.
这些东西不起作用.我认为这是ostringstream的内部问题

thanks for instant reply but i have already done all these things.
these thing are not working. i think its an internal problem of ostringstream


因为您没有仔细阅读文档.

您必须应用fixed操作器(请参见此处的示例[ ^ ]).
:)


Because you didn''t read carefully the documentation.

You have to apply the fixed manipulator (see the example here [^]).
:)




这篇关于ostringstream截断问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 16:51