Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126996 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 654651A00BC for ; Tue, 1 Apr 2025 08:57:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1743497673; bh=8jcNKl7sIAKm/qlUTXDc5GSnYTlngmjypvE7cTmLN1w=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=F4GfSK1EQT7eOmx7ccTZ/KJHZWl0hZ3sScGi/shVK7LmOTBZPJ+kEXOcYPqqvZvlh +G+lU7bxTduN9a6JOhoIP2QK6UNeOWrDmHjozzM+AV71KM8KjA+1Done9MBhFnAQ7Z Ql+QQYl12cHjT/gvvrHjbY7U0lyRg6Ng2S6UbkMPeUwjOLaik939L3Ug/YVHwgkawu nGAWnUfBha6H3mk/UGGVissJrv2JN39RAURgSyCNW1nt12Wq5D1fbIn9Kk/eEPiMmI Eq1dTyowh/K2zqZIsTK2unkrtekYyc7z1xStBLRKssSnrPyYToxog4Fs4FhmEjEUcE p+FBlbhkv63ZQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 49C37180037 for ; Tue, 1 Apr 2025 08:54:32 +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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No 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, 1 Apr 2025 08:54:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1743497817; bh=xvbazBWglFsiiTopRrMfvBbgLnRDx1iEuKokyOytUXs=; h=MIME-Version:Date:From:To:Cc:Subject:In-Reply-To:References: Message-ID:Content-Type:from:to:cc:subject:message-id; b=WadASQpmA0EOg53A81YAHm8t3o4RhrPDHh5ihvphIvPyA59Y/jWZ/Mn5+cyQ5D4cH n3y1h7Ddwq0NyZSEUzss+2PqpSaHtHXIQ9nVF94U7EMS85RzQK8MIlIHe2CEjxiTIY qTRkhlkXrbL5osRgBGFZOyhkl1SGkbZMqWBNmUPUyrmGT8M5ILtbynJC/uZq1HUuBL i3c4rihS15YEvwf+RhRPx3LzfwbhT34wqfjnjXXpGRcVE/vNNNlOt7kc2+C9z1nxSG eHN47ggCmtAf45KP6JjVS/ZoODP9Tk8ZCxRgWkjXE2U2K4GxJihSbsVpGgkZPzF9ew HNxF9I4F23fVw== Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Date: Tue, 01 Apr 2025 10:56:56 +0200 To: Niels Dossche Cc: PHP internals Subject: Re: [PHP-DEV] [RFC brainstorm] Approximately equals operator In-Reply-To: <4a3c6ce7-102d-4cfe-a7a8-35630715b870@gmail.com> References: <4a3c6ce7-102d-4cfe-a7a8-35630715b870@gmail.com> Message-ID: 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 Am 2025-04-01 00:03, schrieb Niels Dossche: > We all had situations where we wanted to compare two floating point > numbers and it turns out that due to the non-exact representation, > seemingly-equal numbers don't match! Gone are those days because the > `~=` operator nicely rounds the numbers for you before comparing them. > This also means that the "Fundamental Theorem of Engineering" now > holds! > i.e. 2.7 ~= 3 and 3.14 ~= 3. Of course also 2.7 ~= 3.14. But this is > false obviously: 2 ~= 1. > Thank you for your proposal. I've tried it and I believe I found some fundamental flaw in the current logic. Consider: