Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:121630 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 80430 invoked from network); 9 Nov 2023 23:01:11 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 9 Nov 2023 23:01:11 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 174141804C1 for ; Thu, 9 Nov 2023 15:01:09 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS9370 160.16.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail.sakiot.com (mail.sakiot.com [160.16.227.216]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 9 Nov 2023 15:01:07 -0800 (PST) Received: from smtpclient.apple (softbank060067217005.bbtec.net [60.67.217.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.sakiot.com (Postfix) with ESMTPSA id 214B84012C; Fri, 10 Nov 2023 08:01:05 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=sakiot.com; s=default; t=1699570865; bh=N0FLOUBisSsFf+q3K3n8bfPjMRKoObhP3uEKm7gpeUU=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=mJknrbK/0LscV4SzK5RwdEx9Py8rWEYaHHPCeegqyS6IOFf+Yr9XtbO0YYa8rsbDa QfH6CwvT5nU7lp/5hDwbYfxzvL9tEyCYxJm7Z3fDyPppB0ztUL9Hwq1HHiF9Yl/76K jolgYldoLEN/RuDyMBQe0ElqHkKXLY1v8yoqb/JY= Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.700.6\)) In-Reply-To: Date: Fri, 10 Nov 2023 08:00:51 +0900 Cc: PHP internals Content-Transfer-Encoding: quoted-printable Message-ID: References: To: Jordan LeDoux X-Mailer: Apple Mail (2.3731.700.6) Subject: Re: [PHP-DEV] [RFC] [Discussion] Change the edge case of round() From: saki@sakiot.com (Saki Takamachi) Hi Jordan, > I think this makes much more sense if PHP programmers had internal = access > to the float type in PHP, but that's not the case. You cannot choose > between float representations, you cannot easily examine the mantissa = bits > directly. In the absence of stuff like that, I think the argument to = treat > PHP floats as if they were decimals for the purposes of rounding is = much > stronger. >=20 > That said, this sort of 'intelligent' rounding certainly introduces a = large > number of edge cases. Additionally, if PHP programmers expect decimal > rounding to "just work", then it feels like anywhere that it doesn't = work > the way they think it should is a bug, which isn't necessarily true. Yes, that's a valid concern. Therefore, I am also proposing to add a = function similar to round to BCMath. In a sense, we can think that we = are looking for the same functionality in round() that we should be = looking for in BCMath. > I'm unsure whether or not this change actually improves anything. Is = it > more correct from a technical perspective? Absolutely. Does it provide = a > benefit for PHP programmers? That I am much less certain about. In terms of "not lying about the results", this RFC makes us more = precise about dealing with FP. However, in terms of benefits for users, = there may not be any significant benefits. Regards. Saki