Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123494 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 56A9E1A009C for ; Mon, 3 Jun 2024 17:03:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1717434248; bh=WT+qDdii1NyNe3mWjle1cCCZ2kgMWrEyxxy89N0s0lY=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=azQNwK6KF0RP8QpOttvocG3E+jeq1yE2REB/C2oDOQ1mJB1tYCbtBXovVV9xOCAVn xdmHNtiK8IGA58kGLpXddQzWzSqEKaU/db1AM53X0FeI6La/NaPViHh3C4NmR4RtMS ZDDQHSJXPeAxyKN5EmLzx1wmgigI9hIINixIp6TY15ZU/6YH47k5+Rp9R3Z9Bh7r0L a1F5/Rr8Xzqkm8HUBlpwJouPVjNQVP1hX7xAkpQ9c1zYRK1rXLWIqIUzBAzNGpArf0 FAc+efgLPQI/9MjJJQx+mWCy28CMlgjgqkaUdY5QXhf8saxQLkxFL8np7p49MBRL7l KOjVLvMhQfesQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C3547180614 for ; Mon, 3 Jun 2024 17:04:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mail-pg1-f176.google.com (mail-pg1-f176.google.com [209.85.215.176]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 3 Jun 2024 17:04:07 +0000 (UTC) Received: by mail-pg1-f176.google.com with SMTP id 41be03b00d2f7-681ad26f4a5so2747527a12.2 for ; Mon, 03 Jun 2024 10:03:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717434183; x=1718038983; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=WT+qDdii1NyNe3mWjle1cCCZ2kgMWrEyxxy89N0s0lY=; b=NjUIUwOmxRqg5b5rHKove8aAYULwnCIK3h/UxSXXmVEdO+638LQKLke+MiJ5yjbUJL DKpdAvYxJ33r0ghA3LH7jkRthAPJuHigwJ3wdQp4PEUViSb9rDWKzqSDgnt8aILqlnCD 12DOmIORhEO/UD88c8PgthzZrPVpoNg7OBpyOGidRgCl3cMe0tkEucHvRF3AzuoWPmjU +E+jiiEwI8Acprzv9vEn/S1wgOpuczSvpc5jULqSWgQzDmn8kEzoCfjY9mWypS7U9Lkn IrUHMJSxUE8DIdOPKx78HQ/dHbRWhsYnMo7W75Aslbk+qbnxmPz4M/GO9Y9wtI868mVw Rg9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717434183; x=1718038983; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=WT+qDdii1NyNe3mWjle1cCCZ2kgMWrEyxxy89N0s0lY=; b=nYI7cr7c+wZIZsjwa/DA1WyttP4NA9CqCJtxXYeAigAvumKLFEdem1m2VW22h4jlCU H5E7GF2NKxdmOQ+e/FOaY1yaWVTcXoCJLoovGzbtKjN20jGAeXXeXZwUZegJlEUNsfj9 6kqtzLJOPDFzYsVoo40YZ/ktx/pXfxiMhBWFeE1GR/HHIOCR34gDEUu+YGQNxcbeLW26 bMdvH4bw5zT+MX4QXUGG1BbxmFDMPX6pcZ2be0rLcsi7KBYMYGkOQhWTE3oPn18Ocua+ ecrxX3DPGpkmONmzaVfXIf0hSM9m/c6W0AMH+Yb2zraSrnBJm2Q+U7uwwOzf6tcFLqbG 8c2g== X-Forwarded-Encrypted: i=1; AJvYcCXdRwdRPHOMLL2mCK7XQqNsBtf1xsITJDmSzQ6FvT0IppEgZdTUeEeGppncym00kZr1iAsBl4oTlImCpv0z8BFBbrNac1WO6w== X-Gm-Message-State: AOJu0YwaAdom7TZWxbgylcCTiSbYJa3EBJD2l2wbHVelRtDWF4fy5v9p A8k9KIo2AFtKtGajLrUN4JVM3fEEE5L/TIhsNB30BLSqWK/86D/urcVR9Gv+a1JGUawWlHKPlMz EzJcydKsI2VlluIwgY3M+65gdPrs= X-Google-Smtp-Source: AGHT+IGFLlNk04DdZn2nNM4YOsyPDzhw9VSC+fAXEqWRSvQ9auOllRvrpXvht35EvGs8cOxvjGZ1VOdo4IO/i6Am+CM= X-Received: by 2002:a17:90a:3f16:b0:2bf:cf50:593e with SMTP id 98e67ed59e1d1-2c1dc57b494mr7804043a91.11.1717434182464; Mon, 03 Jun 2024 10:03:02 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 References: <81CBE5A8-9FAF-40DA-8EAB-9F19C2278E75@sakiot.com> <73ae49a3-473a-46f2-add6-164b0a01e357@app.fastmail.com> <5iUDJtfp_0xWjhfj9MpeJhmZz5awy0RyBF3udkM1TjF5HRfbMKoZrqVNJJWM_g07J1oLDZxsJh_6WbGEaqdNj6ZiE96SjLhfv_r62YTMiRo=@gpb.moe> In-Reply-To: Date: Mon, 3 Jun 2024 10:02:50 -0700 Message-ID: Subject: Re: [PHP-DEV] [RFC] [discussion] Correctly name the rounding mode and make it an Enum To: Jorg Sowa Cc: "Gina P. Banyard" , Larry Garfield , php internals Content-Type: multipart/alternative; boundary="0000000000005f06aa0619ff4e3a" From: jordan.ledoux@gmail.com (Jordan LeDoux) --0000000000005f06aa0619ff4e3a Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sun, Jun 2, 2024 at 2:27=E2=80=AFPM Jorg Sowa wrot= e: > > 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=3Dround%20toward%20positive%20= infinity,ceiling%20math,round%20positive%20infinity,towards%20positive%20in= finity&hl=3Den > > 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 th= at > 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 --0000000000005f06aa0619ff4e3a Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable



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

---

In terms of roun= ding, towards negative/positive infinity and "up" or "down&q= uot; 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 valu= e" and "round towards positive infinity" usually means "= ;round towards positive infinity when it is unclear which direction is clos= er".

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<= /div>
Ceil: -2.8 -> -2
Positive Infinity: -2.8 -> -3

If the behavior of that mode is to ALWAYS round rega= rdless of the value of the remainder, then it should remain ceil IMO. It= 9;s a pretty well understood behavior in many programming languages. Howeve= r, "HALF_TOWARDS_POSITIVE_INFINITY" is a different behavior, and = should not be called ceil.

The bigger issue is tha= t "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
--0000000000005f06aa0619ff4e3a--