macOS/iOS API解説

iOS , Mac アプリケーション開発のために使われる主要フレームワークの日本語情報です。2010年代に書かれた内容です。今後更新はありません。

目次

NSDecimalAdd

十進数の足し算をします。
NSCalculationError  NSDecimalAdd ( 
                    NSDecimal *   result , 
                    const NSDecimal *   leftOperand , 
                    const NSDecimal *   rightOperand , 
                    NSRoundingMode   roundingMode );

解説

十進数の足し算をします。

返り値

引数

( NSDecimal * )result
( const NSDecimal * )leftOperand
( const NSDecimal * )rightOperand
( NSRoundingMode )roundingMode

クラス

NSDecimalAdd

Function

使用可能

10.0

参照

NSCopyObject
NSAllocateObject

例文

#import "MyObject.h"

@implementation MyObject

- (IBAction)myAction:(id)sender
{
NSDecimalNumber *dNum1 = [[[NSDecimalNumber alloc] initWithString:@"5"] autorelease];
NSDecimal number1 = [dNum1 decimalValue];

NSDecimalNumber *dNum2 = [[[NSDecimalNumber alloc] initWithString:@"10"] autorelease];
NSDecimal number2 = [dNum2 decimalValue];

NSCalculationError err;
NSDecimal result;

err = NSDecimalAdd(&result,&number1,&number2,NSRoundBankers);




NSLog(NSDecimalString(&result,nil));

}

@end