ios - Rounding half to even -


what's formula banker's rounding in swift language?

for example: 134.5675 becomes 134 , 135.5345 becomes 136

thus far i've tried this:

extension double {     func roundhalftoeven() -> double {         return round(self * 100) / 100     } } 

but it's near returns need.

remove multiplying , dividing 100. use lrint (instead of round), rounds input nearest integer.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -