

#import "NSString+FloatHandle.h"

@implementation NSString (FloatHandle)
//去除float内小数点后多余的0
+(NSString *)stringFloatHandle:(NSString *)string{

    //122.12020000
    for (NSInteger i=(string.length)-1; i>=0; i--) {
        NSRange range=NSMakeRange(i, 1);
        if ([[string substringWithRange:range]isEqualToString:@"0"]) {
            string=[string substringToIndex:string.length-1];
        }else{
            //判断是否还存在小数点
            if ([[string substringWithRange:range]isEqualToString:@"."]) {
                string=[string substringToIndex:string.length-1];
            }
            break;
        }
    }

    return string;
}
@end
