Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123510 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 9D7D01A009C for ; Tue, 4 Jun 2024 18:17:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1717525084; bh=ne61Futc1c7oX0ntaKhKRZ3XfueU0Cvoq6nuVurXoCY=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=MagTUqio7ri2RV9uKOw3E6+2A2OxzCoPwntcl6HNFgVoYqq6M+ce80HE9wGuRDTII Cg09hmuQledrkqd+xPZlxSrVdTqOd5exxOFOdZxJqpKrsn3QFJ4PB88HQ4A3z2240E D/pkZEPWfw9NrdBmHW8IsoLgK0QNXZFaCWGnZPy40xeEOWNQ+k5jiOTG1V0tZaBXMp QDT/1pwtdUZBCa2WxmhANuNfyAxCi0gVo2463ofNGnDmx/aAql5+I4B4Q8ceRzEbmL 9APMwmoL+zYdvXPh9uSgCMkqjeiZn8fIYxJG1jiCBnOPNSOpaMhJVdHqtCl+mrtDik xiULGM4/a8Wgg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C5D97180749 for ; Tue, 4 Jun 2024 18:18:03 +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,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 chrono.xqk7.com (chrono.xqk7.com [176.9.45.72]) (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 ; Tue, 4 Jun 2024 18:18:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1717525018; bh=SdzRiY3DM9FbZTwAODwe8/06+c3F8E7Bo+sObVQdrJc=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type:from:to:cc:subject:message-id; b=f/brHWmjtxgjEC6i9w+T0fkSTf9em7rKtWy3N59q+YAY3IHbN5j3sBVSUcWD24Wdy GlSdL3VHMj7QQC9MIzPKYi9k4S/yTMoZsjZ2tOocIRBae+HHow1s9Q0FQAa9zWEidH GeJslFuU3m4+Bb07jd1NQFCQKgBZG9umQGCWok05AtBP8RXHiAq2j2t7rm8gpNPPTa HMiBO7uAQ4WADTkxkXKJHdA1qkt2sMxIgjDSswzrmkHu4bxn9Z2DXWfnqvn0l4AHZQ dMHChIOfTvxMSzB/PP6zwQErGGadxxQCNCENogxbxcH/kSsiybtkcbroNJVWxyOSnm 33C7OGcXAQR+g== Message-ID: <1ca7b52f-956f-4fad-a4c7-b9ed2a02d2d9@bastelstu.be> Date: Tue, 4 Jun 2024 20:16:56 +0200 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Subject: Re: [PHP-DEV] [RFC] [discussion] Correctly name the rounding mode and make it an Enum To: Derick Rethans , Saki Takamachi Cc: php internals References: <81CBE5A8-9FAF-40DA-8EAB-9F19C2278E75@sakiot.com> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit From: tim@bastelstu.be (=?UTF-8?Q?Tim_D=C3=BCsterhus?=) Hi On 6/3/24 18:23, Derick Rethans wrote: >> I would like to start an RFC discussion regarding rounding modes. >> https://wiki.php.net/rfc/correctly_name_the_rounding_mode_and_make_it_an_enum > > I think it would be really helpful to have a description (and examples) > for each of the rounding modes in the Enum > (https://wiki.php.net/rfc/correctly_name_the_rounding_mode_and_make_it_an_enum#proposal) > — that'd also be great for creating documentation later on. The `RoundingMode` enum will not provide any new rounding modes, thus the existing documentation of rounding modes applies. The corresponding constant names have been mentioned. Nevertheless I've just added a PHPDoc with a brief definition and examples to each of the enum cases. Please note: The definition is a little simplified to make it easier to understand the differences on a conceptual level. It assumes arbitrary precision (which floats do not provide) and it assumes that rounding always rounds to integer values. In reality the round() function supports a specified number of decimal digits, with integer rounding being rounding to 0 decimal digits. An integer rounding function can emulate rounding to a specific number of decimal digits by multiplying the input value by 10**$digits, performing integer rounding, and then dividing by 10**$digits (assuming arbitrary precision). There's also a helpful table on Wikipedia: https://en.wikipedia.org/wiki/Rounding#Comparison_of_approaches_for_rounding_to_an_integer Hope this helps. Best regards Tim Düsterhus