xcode - How to round an NSDecimalNumber in swift? -


i can't find resources on this, , i've been trying sorts of stuff, nothing works.

according apple's documentation, round nsdecimalnumber this:

nsdecimalnumber.decimalnumberbyroundingaccordingtobehavior(<#behavior: nsdecimalnumberbehaviors?#>) 

it takes in nsdecimalnumberbehavior, i'm unsure how manipulate since (1) cannot initiated variable , have it's properties changed, , (2) roundingmode() method according documentation doesn't take parameters, xcode fills in parameter space "self".

i'm totally lost on this. basic question; how can round nsdecimalnumber in swift?

thanks in advance

you can that

let x = 5 let y = 2 let total = x.decimalnumberbydividingby(y).decimalnumberbyroundingaccordingtobehavior( nsdecimalnumberhandler(roundingmode: nsroundingmode.roundup, scale: 0, raiseonexactness: false, raiseonoverflow: false, raiseonunderflow: false, raiseondividebyzero: false))    

Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

excel vba - VBA Proxy auto-configuration for http requests -

sql server 2008 - split ssrs expression between 2 words -