On Sun, Jun 2, 2024 at 2:27 PM Jorg Sowa <jorg.s...@gmail.com> wrote:

> > It should also be noted that ceil/floor is very English specific
> terminology that may not be immediately obvious to non-English speakers,
> thus my preference for using some variation of towards positive/negative
> infinity.
>
> This statement is subjective in my opinion. For me, it's the contrary,
> that's why I'm opposing introducing new terms to the PHP replacing ones
> that already exist (ceil()/floor()). I don't have the data on such modes in
> other programming languages, but I checked the data in Google Trends:
>
> https://trends.google.com/trends/explore?q=round%20toward%20positive%20infinity,ceiling%20math,round%20positive%20infinity,towards%20positive%20infinity&hl=en
>
> Far more people search for `ceiling` than `round toward positive infinity`
> or `round positive infinity`. Of course, I may be wrong by choosing
> incorrect search phrases, but it's also good to see some data/examples that
> changing this in PHP is for the better.
>

Well, probably plenty of people searching for "ceiling" who are remodeling
their house so that statistic is probably completely useless.

---

In terms of rounding, towards negative/positive infinity and "up" or "down"
are almost always synonyms. There IS a difference (in general) between the
terms "round towards positive infinity" and "ceil" however. They are
rounding in the same direction, however "ceil" usually means "round towards
positive infinity regardless of the value" and "round towards positive
infinity" usually means "round towards positive infinity when it is unclear
which direction is closer".

For instance (typical behavior meaning):

Ceil: 2.1 -> 3
Positive Infinity: 2.1 -> 2
Ceil: 2.5 -> 3
Positive Infinity: 2.5 -> 3
Ceil: -2.1 -> -2
Positive Infinity: -2.1 -> -2
Ceil: -2.5 -> -2
Positive Infinity: -2.5 -> -2
Ceil: -2.8 -> -2
Positive Infinity: -2.8 -> -3

If the behavior of that mode is to ALWAYS round regardless of the value of
the remainder, then it should remain ceil IMO. It's a pretty well
understood behavior in many programming languages. However,
"HALF_TOWARDS_POSITIVE_INFINITY" is a different behavior, and should not be
called ceil.

The bigger issue is that "HALF_UP" and "HALF_DOWN" are utterly and
completely incorrectly named. Those absolutely should be changed to
something sensible, and is FAR more important IMO than this discussion
about ceil.

Jordan

Reply via email to