首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::moneypunct::decimal_point

Defined in header <locale>

public: CharT decimal_point() const;

(1)

protected: virtual CharT do_decimal_point() const;

(2)

1%29公共成员函数,调用成员函数do_decimal_point最派生的类。

2%29返回货币I/O中用作小数点分隔符的字符,如果格式使用分数%28,即如果do_frac_digits()大于0%29。对于典型的美国地区来说,这是一个字符'.'%28或L'.'%29

返回值

类型对象CharT保持小数点字符。

二次

代码语言:javascript
复制
#include <iostream>
#include <iomanip>
#include <locale>
 
void show_dpt(const char* locname)
{
    std::locale loc(locname);
    std::cout.imbue(loc);
    std::cout << locname << " decimal point is '"
              << std::use_facet<std::moneypunct<char>>(loc).decimal_point()
              << "' for example: " << std::showbase << std::put_money(123);
    if (std::use_facet<std::moneypunct<char>>(loc).frac_digits() == 0)
        std::cout << " (does not use frac digits) ";
 
    std::cout << '\n';
}
 
int main()
{
    show_dpt("en_US.utf8");
    show_dpt("ja_JP.utf8");
    show_dpt("sv_SE.utf8");
    show_dpt("de_DE.utf8");
 
}

二次

产出:

二次

代码语言:javascript
复制
en_US.utf8 decimal point is '.' for example: $1.23
ja_JP.utf8 decimal point is '.' for example: ¥123 (does not use frac digits)
sv_SE.utf8 decimal point is ',' for example: 1,23 kr
de_DE.utf8 decimal point is ',' for example: 1,23 €

二次

另见

do_frac_digits virtual

provides the number of digits to display after the decimal point (virtual protected member function)

代码语言:txt
复制
 © cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券