iOS 数字字符串的直接运算 + - * /


NSDecimalNumber *d1 = [NSDecimalNumber decimalNumberWithString:@"3.14"];

    NSDecimalNumber *d2 = [NSDecimalNumber decimalNumberWithString:@"2"];

   

    NSDecimalNumber *s = [d1 decimalNumberByAdding:d2];

    NSLog(@"s = %@",s);

    s = [d1 decimalNumberBySubtracting:d2];

    NSLog(@"s = %@",s);

    s = [d1 decimalNumberByMultiplyingBy:d2];

    NSLog(@"s = %@",s);

    s = [d1 decimalNumberByDividingBy:d2];

    NSLog(@"s = %@",s);


注意!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。



 
粤ICP备14056181号  © 2014-2020 ITdaan.com