Hi Rowan, > Yes, I agree there's a dilemma there. > > The extra point in favour of TOWARD_ZERO is that it's more efficient, because > we don't have to over-calculate and round, just pass scale directly to the > implementation. Any other option makes for unnecessary extra calculation in > code like this: > > $total = new Number('20'); > $raw_frac = $total / 7; > $rounded_frac = $raw_frac->round(2, Round::HALF_UP); > > If HALF_UP rounding is the implied default, we have to calculate with scale > 11 giving 1.42857142857, round to 1.4285714286, then round again to 1.43. > > If truncation / TOWARD_ZERO is the implied default, we only calculate with > scale 10 giving 1.4285714285 and then round once to 1.43. > > (Of course, in this example, the most efficient would be for the user to > write $rounded_frac = $total->div(7, 2, Round::HALF_UP) but they might have > reasons to keep the division and rounding separate.)
Thanks, when I expand on this issue, I'll also mention the pros and cons of both, including the points you mentioned. Regards, Saki