1

我面临一个问题NSDecimalNumber。我有类似于下面的代码。

NSDecimalNumber *n1 = [NSDecimalNumber decimalNumberWithString: @"1e-80"];
NSDecimalNumber *n2 = [NSDecimalNumber decimalNumberWithString: @"1e-80"];
NSDecimalNumber *n3 = [n1 decimalNumberByMultiplyingBy: n2 withBehavior: [NSDecimalNumberHandler decimalNumberHandlerWithRoundingMode: NSRoundPlain
                                                                             scale: 127
                                                                  raiseOnExactness: TRUE
                                                                   raiseOnOverflow: TRUE
                                                                  raiseOnUnderflow: TRUE
                                                               raiseOnDivideByZero: TRUE]];
NSLog(@"result=%@", [n3 descriptionWithLocale: [NSLocale autoupdatingCurrentLocale]]);

上面的代码正在打印结果1e+98,这是不正确的;它应该为零。我在这里想念什么?

4

0 回答 0