如何确定语言环境货币是否有小数点

How to determine if locale currency has a decimal point

objective-c 是否有确定货币是否使用小数点的方法(无论声明的 NSNumber 类型如何)?

我有多个语言环境,我使用 NSNumberFormatter(基于语言环境)来设置字符串货币字符串样式,但是事先我想知道所选语言环境货币是否使用小数点。

[_cf setLocale:
[NSLocale localeWithLocaleIndentifier:[NSString stringWithFormat:@"%@",locale]]]];
[cf setNumberStyle:NSNUmberFormatterCurrencyStyle];
NSString *value = [cf stringFromNumber:price];
return value;

创建带有货币样式的NSNumberFormatter后,询问格式化程序它有多少个小数位。

NSInteger maxFractionDigits = cf.maximumFractionDigits;
if (maxFractionDigits == 0) {
    // this currency is an integer, not a decimal
}

一个例子是日元 (¥)。