On Fri, Jul 21, 2023 at 3:48 PM Jorg Sowa <jorg.s...@gmail.com> wrote:
> Thank you for your suggestions. I added two remaining modes and I think > it's complete now. > > I changed the names to `PHP_ROUND_CEILING` and `PHP_ROUND_FLOOR` to be > consisted with rounding modes in number_format() function. I'm not sure > about `PHP_TOWARD_ZERO` and 'PHP_AWAY_FROM_ZERO` as in there it's > `ROUND_DOWN` and `ROUND_UP`, which I also find too vague. > > However, I could find names UP and DOWN in other documentations. And sadly > it refers to away from zero and toward zero, so there is big mismatch in > existing naming. > > > https://developer.apple.com/documentation/foundation/numberformatter/roundingmode/down > > https://docs.oracle.com/en/java/javase/20/docs/api/java.base/java/math/RoundingMode.html > I had to deal with this issue when I was doing the rounding modes for my math library in PHP. I ended up providing the following rounding modes: - Half Up (Positive Infinity) - Half Down (Negative Infinity) - Half Even - Half Odd - Half Zero - Half Infinity (Closest) - Half Random (50% chance of either direction) - Half Alternating (Each subsequent call to round alternates rounding direction) - Stochastic (Chance of direction based on proximity... i.e. 1.7 rounds to 2 70% of the time, and rounds to 1 30% of the time) The only reason I used "Half Up" and "Half Down" is because I also used "Half Zero" and "Half Infinity" so it was more clear there were differences. Stochastic is probably the one that sounds weirdest to most people, but is insanely useful for applications like Machine Learning. Jordan