目标c -在IOS上打印漂亮的大数
objective c - Printing nice large numbers c++ on IOS
我正在寻找一种很好的方法来打印大数,使它们更易于阅读
即6000000
应该6.000.000
或
6,000,000,取决于语言环境
更新我已经尝试了以下我的代码(它在IOS上)
char* localeSet = std::setlocale(LC_ALL, "en_US");
cout << "LOCALE AFTER :" << std::locale("").name() << endl;
localeSet总是nil
和我总是得到"LCOALE AFTER: C"
在std c++中如下所示:
template < class T >
std::string Format( T number )
{
std::stringstream ss;
ss << number;
const std::string num = ss.str();
std::string result;
const size_t size = num.size();
for ( size_t i = 0; i < size; ++i )
{
if ( i % 3 == 0 && i != 0 )
result = '.' + result;
result = ( num[ size - 1 - i ] + result );
}
return result;
}
...
long x = 1234567;
std::cout << Format( x ) << std::endl;
...
相关文章:
- 如何使用gdb制作一个可以漂亮地打印每个对象的C++函数
- 使用 Boost HOF 实现 STL 漂亮打印
- 在wxWidgets中漂亮地打印XML
- 在 Eclipse 中漂亮的打印C++适用于某些项目,而不适用于其他项目
- 漂亮的打印与libxml2
- 漂亮的打印不适用于C ++ STL列表
- 使用JSON Spirit进行漂亮打印
- Mac漂亮打印GDB
- Rapidjson漂亮的打印使用JSON字符串作为作者的输入
- boost::p roperty_tree XML 漂亮的打印,格式化
- C++ GDB Python 漂亮的打印教程
- 如何在编译时漂亮地打印模板参数的名称
- 漂亮地打印一个C++中的变量和值列表
- c++中使用的缩进和漂亮打印之间的区别是什么
- 所有类的漂亮打印,带有用于循环支持的范围基础
- 使用 GDB 的 Python 漂亮打印不支持地图的索引运算符 []
- GDB 漂亮打印导入错误:没有名为"打印机"的模块
- 如何从 dbx 的漂亮打印函数调用 dbx 自己的打印函数
- Eclipse/CDT漂亮打印与远程调试
- 漂亮打印类型和类模板及其所有模板参数