algorithm - How to round currency values -
i have several ways solve this, interested in whether there better solution problem. please respond pure numeric algorithm. string manipulation not acceptable. looking elegant , efficient solution.
given currency value (ie $251.03), split value 2 half , round 2 decimal places. key first half should round , second should round down. outcome in scenario should $125.52 , $125.51.
divide two, round 2 d.p. (in c# decimal.round(value, 2)
), subtract rounded value original, , sort them using if. library may support control on rounding can save if - c# can using 3-parameter overload of decimal.round
.
Comments
Post a Comment