std :: to_string(double)的精度 [英] The precision of std::to_string(double)
本文介绍了std :: to_string(double)的精度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用std :: to_string()将double转换为字符串时,是否有任何方法可以设置结果的精度?
Is there any way to set the precision of the result when converting a double to string using std::to_string()?
推荐答案
否。
返回:每个函数返回一个字符串对象,它保存
值的字符表示形式它的参数将通过调用sprintf(buf,fmt,val)具有
%d,%u,%ld,%lu,%lld,%llu,%f,%f的格式说明符%Lf,其中buf表示
一个足够大小的内部字符缓冲区。No.
Returns: Each function returns a string object holding the character representation of the value of its argument that would be generated by calling sprintf(buf, fmt, val) with a format specifier of "%d", "%u", "%ld", "%lu", "%lld", "%llu", "%f", "%f", or "%Lf", respectively, where buf designates an internal character buffer of sufficient size.
这篇关于std :: to_string(double)的精度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文