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