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
Post a Comment