Swift Round up / Max the NSDecimalNumber -


let's have nsdecimal constant called total , contains value of 3.33333333 divided 10/3. 10 , 3 both nsdecimalnumber. want total 4 nsdecimalnumber in swift.

let total = ten/three  // ideal total rounded whenever there floating  

in doc. have

func nsdecimalround(_ result: unsafemutablepointer<nsdecimal>,                   _ number: unsafepointer<nsdecimal>,                   _ scale: int,                   _ roundingmode: nsroundingmode)   maximumdecimalnumber() 

which 1 best fit calculator currency style? please include example each how use them if know so. thank .

let x = nsdecimalnumber(string:"10") let y = nsdecimalnumber(string:"3") let total = x.decimalnumberbydividingby(y).decimalnumberbyroundingaccordingtobehavior( nsdecimalnumberhandler(roundingmode: nsroundingmode.roundup, scale: 0, raiseonexactness: false, raiseonoverflow: false, raiseonunderflow: false, raiseondividebyzero: false))   // 4 

Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -