我有以下法典:
(...)
numberStyle = [NSDecimalNumberHandler decimalNumberHandlerWithRoundingMode:NSRoundPlain
scale:2
raiseOnExactness:NO
raiseOnOverflow:NO
raiseOnUnderflow:NO
raiseOnDivideByZero:NO];
strThree = textFieldThree.text;
strThree = [strThree stringByReplacingOccurrencesOfString:@"." withString:@""];
fieldOneDNa = (NSDecimalNumber *)[NSDecimalNumber decimalNumberWithString:strThree];
oneHundred = (NSDecimalNumber *)[NSDecimalNumber decimalNumberWithString:@"100"];
fieldOneDN = [fieldOneDNa decimalNumberByDividingBy:oneHundred
withBehavior:numberStyle];
firstStepReturn = [fieldOneDN stringValue];
textFieldThree.text = firstStepReturn;
(...)
即便是零位或0位位数,我还是能够拥有位数位位位数。 例如,如果将323.390条输入文本领域“案文领域3”的话,则将予以处理,并退回到文本领域,即为3233.90。 目前,它显示为3233.9。
任何帮助都将受到高度赞赏。