NSDecimalRound
十進数を丸めて参照で返します
void NSDecimalRound ( NSDecimal * result , const NSDecimal * number , int scale , NSRoundingMode roundingMode );
解説
十進数を丸めて参照で返します。
● NSRoundDown 切り下げ
● NSRoundUp 切り上げ
● NSRoundPlain 四捨五入
● NSRoundBankers
返り値
引数
( NSDecimal * )result
( const NSDecimal * )number
( int )scale
( NSRoundingMode )roundingMode
フレームワーク
Foundation
クラス
NSDecimalRound
Function
使用可能
10.0
参照
例文
#import "MyObject.h" @implementation MyObject - (IBAction)myAction:(id)sender { NSDecimalNumber *dNum1 = [[[NSDecimalNumber alloc] initWithString:@"3000.2345"] autorelease]; NSDecimal dec = [dNum1 decimalValue]; NSDecimal result; double dbl; NSDecimalRound(&result, &dec , 2, NSRoundDown); dbl = [[NSDecimalNumber decimalNumberWithDecimal:result] doubleValue]; NSLog([NSString stringWithFormat:@"%.5f",dbl]); } @end