本文整理汇总了C++中StringStream::precision方法的典型用法代码示例。如果您正苦于以下问题:C++ StringStream::precision方法的具体用法?C++ StringStream::precision怎么用?C++ StringStream::precision使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringStream
的用法示例。
在下文中一共展示了StringStream::precision方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DoWriteFloat
String CDatabaseConnectionMySql::DoWriteFloat( float value ) const
{
StringStream stream;
uint32_t decimals = GetPrecision( EFieldType_FLOAT32 );
stream << STR( "CAST( " );
stream.precision( decimals * 2 );
stream << value;
// float min == -3.40282e+038 => 39 digits before decimals separator
stream << STR( " AS DECIMAL( " ) << ( 39 + decimals ) << STR( ", " ) << decimals << STR( " ) )" );
return stream.str();
}
示例2: toString
//-----------------------------------------------------------------------
String StringConverter::toString(double val, unsigned short precision,
unsigned short width, char fill, std::ios::fmtflags flags)
{
StringStream stream;
stream.precision(precision);
stream.width(width);
stream.fill(fill);
if (flags)
stream.setf(flags);
stream << val;
return stream.str();
}
示例3: toString
//-----------------------------------------------------------------------
String StringConverter::toString(float val, unsigned short precision,
unsigned short width, char fill, std::ios::fmtflags flags)
{
StringStream stream;
if (msUseLocale)
stream.imbue(msLocale);
stream.precision(precision);
stream.width(width);
stream.fill(fill);
if (flags)
stream.setf(flags);
stream << val;
return stream.str();
}