Namespaces
Variants

std::moneypunct<CharT,International>:: frac_digits, do_frac_digits

From cppreference.net
헤더에 정의됨 <locale>
public :
int frac_digits ( ) const ;
(1)
protected :
virtual int do_frac_digits ( ) const ;
(2)
1) Public 멤버 함수, 가장 파생된 클래스의 do_frac_digits 멤버 함수를 호출합니다.
2) 통화 값을 출력할 때 소수점 이하에 표시할 자릿수를 반환합니다.

반환값

소수점 이하에 표시될 자릿수. 일반적인 미국 로캘에서는 이 값이 2 입니다.

예제

#include <iomanip>
#include <iostream>
#include <iterator>
#include <locale>
struct space_out : std::moneypunct<char>
{
    pattern do_pos_format() const { return {value, none, none, none}; }
    int do_frac_digits() const { return 0; }
    char_type do_thousands_sep() const { return ' '; }
    string_type do_grouping() const { return "\002"; }
};
int main()
{
    std::cout.imbue(std::locale("en_US.UTF-8"));
    std::cout << "american locale: " << std::showbase
              << std::put_money(12345678.0) << '\n';
    std::cout.imbue(std::locale(std::cout.getloc(), new space_out));
    std::cout << "locale with modified moneypunct: "
              << std::put_money(12345678.0) << '\n';
}

출력:

american locale: $123,456.78
locale with modified moneypunct: 12 34 56 78

참고 항목

천 단위 구분자로 사용할 문자를 제공함
(가상 protected 멤버 함수)
소수점으로 사용할 문자를 제공함
(가상 protected 멤버 함수)