nsdecimalnumber - Examples of doing decimal math in iPhone -
i'm pulling decimal values sql table text field convert nsdecimalnumber (this because didnt know read/write decimal values sqllite).
anyway, i've hit wall im trying simple math routines on these decimal variables. such as, sum = balance * interest_rate. idea im working money calculations.
do know of samples/tutorials teaches how these operations using either nsdecimal, nsdecimalnumber, or both?
thanks.
to init:
nsstring *number = @"123.4"; nsdecimalnumber *mydecimal = [[nsdecimalnumber alloc] initwithstring: number];
to want do:
nsdecimalnumber *sum = [[nsdecimalnumber alloc] initwithdecimal:[balance decimalnumberbymultiplyingby: interest_rate];
how?
well make nsdecimalnumber , alloc , initwithdecimal. decimal? balance multiplied (decimalnumberbymultiplyingby) interest_rate.
Comments
Post a Comment