Newsgroups: php.internals
Path: news.php.net
Xref: news.php.net php.internals:122602
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 0EF491AD8F6
	for <internals@lists.php.net>; Sun, 10 Mar 2024 15:52:31 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail;
	t=1710085965; bh=rR7l/tqQWJX2KPl29iLzgTdhyUxQOBoIx5sHSFfq/nY=;
	h=In-Reply-To:References:Date:From:To:Subject:From;
	b=WE8k4Yp0mHP62ZMF1/u2DKlwPWXWtQRUVEGM7FjVpfQn/TswAPpef2dDLBH2q7uX4
	 Cxc+Gbjbwe5aE/TpswjdjOCQ4/+a8zuWkAG/duKz19oo7E3Od4QKfVkra+7cq5KT8/
	 NLMgbdjol0ForF7nAJGf8Yk4f34fkqB6UL6osfbh1fXOiTjTdKUxuzp+oTM30GY1Nb
	 x0KE763P1VRLcQVNh4XULf1BTt05RUIJRqsjDrwVtK2WAEQbXGlVZCE+6hNLtyBiYH
	 Br7NbJv6vOv7hbWnFi+ELhEqEgdwoJ30pQS9xPYdfJXFEaeABXRU0WoiFTgQXPm5wo
	 k5/9uf2SkGJ8Q==
Received: from php-smtp4.php.net (localhost [127.0.0.1])
	by php-smtp4.php.net (Postfix) with ESMTP id 3F77A1804AC
	for <internals@lists.php.net>; Sun, 10 Mar 2024 15:52:44 +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.1 required=5.0 tests=BAYES_50,DKIM_SIGNED,
	DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_DNSWL_LOW,
	SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no
	autolearn_force=no version=4.0.0
X-Spam-Virus: No
X-Envelope-From: <larry@garfieldtech.com>
Received: from wout3-smtp.messagingengine.com (wout3-smtp.messagingengine.com [64.147.123.19])
	(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 <internals@lists.php.net>; Sun, 10 Mar 2024 15:52:43 +0000 (UTC)
Received: from compute1.internal (compute1.nyi.internal [10.202.2.41])
	by mailout.west.internal (Postfix) with ESMTP id 354293200258
	for <internals@lists.php.net>; Sun, 10 Mar 2024 11:52:27 -0400 (EDT)
Received: from imap50 ([10.202.2.100])
  by compute1.internal (MEProxy); Sun, 10 Mar 2024 11:52:27 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
	garfieldtech.com; h=cc:content-type:content-type:date:date:from
	:from:in-reply-to:in-reply-to:message-id:mime-version:references
	:reply-to:subject:subject:to:to; s=fm1; t=1710085946; x=
	1710172346; bh=U6PjoSclvTkl4CmCRPxg5LCzi6UtoNyZ4GDiW+4uMhQ=; b=d
	65VMg/3ic/giiQH74ykF+ZgfLDjTk7Pz9wnktduKwreOx+YSTSofXt/5okNKYSH8
	TBqGvPhJZylhA26UPkcl1TGg2dksKdW6j5U8TWXXihV27zFa02uWPgqC6OSYsBvi
	LzKV9vgW5sy3rJ6siJB9ygjYtFNoYeqwUlEPLVOAYiUnVW+HU4FiK0FuGz5nKmZo
	kNkrPWfM46NkWNGcKDdHUqAioyUXxCyKCiLEKKb8vSvWv896bJJYFonNDDxxwnNG
	/0NO7YT3n/3TDTnsUE6HUHrvKBkoEhyIdcNBWqIJJKpoyXV7+j7+2JKd64P3qvc4
	/2ahpouiebIeP0DarPHAg==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
	messagingengine.com; h=cc:content-type:content-type:date:date
	:feedback-id:feedback-id:from:from:in-reply-to:in-reply-to
	:message-id:mime-version:references:reply-to:subject:subject:to
	:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=
	fm1; t=1710085946; x=1710172346; bh=U6PjoSclvTkl4CmCRPxg5LCzi6Ut
	oNyZ4GDiW+4uMhQ=; b=LGhzfamAzHXEiFaMRmFqnXsG1olG51h0QwFuAp6krEzn
	UYBfc2/OwT1XkDqifzKTQe5SzW2rMw9BvYvl6abDcsZMw/Lw8L/punPi+OtPvIhU
	u+t90fDXBO3ixKsUi60dwAP3j+8v6JV1QKbc9FO18kIOCYl6W72BXR1894LKrv/c
	8pessuls6MW9MB3tKcteHpf2f/IDf/ME+C4xBoG2ZaDcDVRli9JFUa1kT8zroLRT
	dqp0e3dZX+vBfSaFsVomwGCbpmNvZckmjDPXlaMEK9iPmJ4DQA72tNWI/GzqCPpU
	ju/yIKIZ5Gdi+C83c4w18MacHhhRUR06VZzGwSi3pA==
X-ME-Sender: <xms:OtftZe7rA8K4VJDJcgpdCP86B9VGWCynv4f_UGujSEV5FkVI8tQDkA>
    <xme:OtftZX5kAU03Y57BIJGz0fSvXxsCdWifT72KxGCRjP3fKaXxoulIyu4TGhOI2mglf
    Nm-EHX-Ohp4lg>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrieelgdekudcutefuodetggdotefrodftvf
    curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu
    uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc
    fjughrpefofgggkfgjfhffhffvufgtsehttdertderredtnecuhfhrohhmpedfnfgrrhhr
    hicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomh
    eqnecuggftrfgrthhtvghrnhepgeelgfekudeivddvteffueejffdthfejieevhefgffek
    udevkedtvdelvddvffefnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrg
    hilhhfrhhomheplhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhm
X-ME-Proxy: <xmx:OtftZddVaemTnF1U9taFkJbjIkBZtKLCWBYnd6xGUwRiyZJZOsZwZw>
    <xmx:OtftZbIiEN4WcHGaED-KjFt8GJCyzmJBwH7NaMY3wSBChRXeDl5yIw>
    <xmx:OtftZSJ2ZqBC4tnY47lIeCCOj2dy0r2Jb2dWgpPdthRDGtniVGKhJA>
    <xmx:OtftZZYGt3t6QS6d1h16ISF6Y60KhpCpuT5Vm6qurjHu203dw7fR8Q>
Feedback-ID: i8414410d:Fastmail
Received: by mailuser.nyi.internal (Postfix, from userid 501)
	id 69BFA1700093; Sun, 10 Mar 2024 11:52:26 -0400 (EDT)
X-Mailer: MessagingEngine.com Webmail Interface
User-Agent: Cyrus-JMAP/3.11.0-alpha0-251-g8332da0bf6-fm-20240305.001-g8332da0b
Precedence: bulk
list-help: <mailto:internals+help@lists.php.net
list-unsubscribe: <mailto:internals+unsubscribe@lists.php.net>
list-post: <mailto:internals@lists.php.net>
List-Id: internals.lists.php.net
MIME-Version: 1.0
Message-ID: <290788fe-57cc-42e1-bc74-85a768cdf63d@app.fastmail.com>
In-Reply-To: 
 <EIeXRgEfkctuEBHawJxwjtswKsCwLhmxtWCgMpPZnfr3aj2BYERIPUU_lYIRUBDubfWjxXJfzLIDZZh0EK5NqaR2Y05Tya1-ECcvZQl5DGc=@gpb.moe>
References: <a973a0f1-6a1d-0219-2059-823d2db497d4@mabe.berlin>
 <07407c20-09ea-4bb9-a5cf-3af41b9234ee@mabe.berlin>
 <8a96a374-eaf8-4ac6-b45c-61d2a0c9652f@mabe.berlin>
 <73b032ec-b41a-4b96-8254-f0b68abf87f2@app.fastmail.com>
 <EIeXRgEfkctuEBHawJxwjtswKsCwLhmxtWCgMpPZnfr3aj2BYERIPUU_lYIRUBDubfWjxXJfzLIDZZh0EK5NqaR2Y05Tya1-ECcvZQl5DGc=@gpb.moe>
Date: Sun, 10 Mar 2024 10:52:06 -0500
To: "php internals" <internals@lists.php.net>
Subject: Re: [PHP-DEV] [RFC] [Discussion] Rounding Integers as int
Content-Type: text/plain
From: larry@garfieldtech.com ("Larry Garfield")

On Sun, Mar 10, 2024, at 10:31 AM, Gina P. Banyard wrote:
> On Saturday, 9 March 2024 at 16:00, Larry Garfield 
> <larry@garfieldtech.com> wrote:
>
>> I am still opposed to this. Logically, ceil/float/round should be returning ints, not floats. Only returning ints if it was given an int is, er, kinda pointless, as you'll just get back the value you passed in. (Because it's already rounded/floored, etc.) So this doesn't get us any new type safety, but does make the return type less consistent than it is today. That's a step backwards.
>> 
>> If there's some math reason that we cannot have those functions return int (someone mentioned there was, but I don't really understand it and the RFC does not explain it at all), then we should at least keep consistency in the return type. "Sometimes I have to cast the return value before I can actually use it in the obvious way, sometimes I don't" is not a good situation.
>> 
>> --Larry Garfield
>
> There are plenty of values that are exactly representable as floating 
> point numbers but not as integers.
>
> One short example:
>
> $v = 1e10 + 0.6;
> var_dump($v);
> var_dump(round($v));
>
> Gives you accurate precision and proper rounding behaviour.
>
> 1e10 *cannot* be represented as an integer.
>
> So round *must* be able to return a float.
>
> Best regards,
>
> Gina P. Banyard

Please include some version of this in the RFC.  Especially if it can be even more detailed.

--Larry Garfield