iOS开发bug以及解决方案iOS程序猿iOS收藏

支付金额精度问题

2016-08-28  本文已影响321人  AT19
    -(NSString *)getStringFromDouble:(double)needToPayMoney {
            NSString *moneyStr = [NSString  stringWithFormat:@"%lf",needToPayMoney];
            NSRange range = [moneyStr rangeOfString:@"."];
            NSUInteger location = range.location;
            NSString *needToPayFact = [moneyStr substringToIndex:location + 3];
           return needToPayFact;    
  }   
上一篇 下一篇

猜你喜欢

热点阅读