阿拉伯数字转汉字

遇到需要将数字转汉字的需求,如下:1转一  原值 1.59999999

typedef CF_ENUM(CFIndex, CFNumberFormatterRoundingMode) {

kCFNumberFormatterRoundCeiling = 0,//四舍五入,直接输出2

kCFNumberFormatterRoundFloor = 1,//保留小数输出1.6

kCFNumberFormatterRoundDown = 2,//加上了人民币标志,原值输出¥1.6

kCFNumberFormatterRoundUp = 3,//本身数值乘以100后用百分号表示,输出160%

kCFNumberFormatterRoundHalfEven = 4,//输出1.5999999E0

kCFNumberFormatterRoundHalfDown = 5,//原值的中文表示,输出一点五九九...

kCFNumberFormatterRoundHalfUp = 6//原值中文表示,输出第二

};

方法:

+ (NSString*)stringWithNumber:(int)number

{

NSNumberFormatter*formatter = [[NSNumberFormatteralloc]init];

formatter.numberStyle=kCFNumberFormatterRoundHalfDown;

return[formatterstringFromNumber:[NSNumbernumberWithInt:number]];

}

你可能感兴趣的:(阿拉伯数字转汉字)