Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128298 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 lists.php.net (Postfix) with ESMTPS id C74311A00BC for ; Tue, 29 Jul 2025 16:04:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1753804966; bh=3Z9KG90IWyVqOuc6f5jqWBIvkIkTXHUrQ1Uic2q3WbQ=; h=Date:From:To:In-Reply-To:References:Subject:From; b=AmPhFWgmu87/SwqzYrhlo6jjRzukumcJQroUa2eI92+aQpnjvdKSjTseutHeoyFJR pHTy93kf9RBIyOaweb50GYjpRDcMWpa2excOd9QP7jQKCQIdb+9C/9ThfFZIFAnzat i4qxzzLDzWj/6Dg1bnD5pHD9P2mdrAFNQorF9qqL2PzHqdUI6K87dORpRVf6jlmZ8p b0/Ox9NXHzs5vn58LJ0vMtgjPD0Gt4wkcSAcVCnodp8frTuU80MZPu4VjkT4jvaFPL gw24ySheVJ27oLC2e0VK9cCdyw24CI39Cc7uKhxrINOWgF6BIhWlVPXlFBCDGx7c7t /tDwNf8Q+V1Pg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 4269E1804CF for ; Tue, 29 Jul 2025 16:02:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from fhigh-b4-smtp.messagingengine.com (fhigh-b4-smtp.messagingengine.com [202.12.124.155]) (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, 29 Jul 2025 16:02:46 +0000 (UTC) Received: from phl-compute-10.internal (phl-compute-10.phl.internal [10.202.2.50]) by mailfhigh.stl.internal (Postfix) with ESMTP id 7CFE37A0124 for ; Tue, 29 Jul 2025 12:04:28 -0400 (EDT) Received: from phl-imap-02 ([10.202.2.81]) by phl-compute-10.internal (MEProxy); Tue, 29 Jul 2025 12:04:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc:content-transfer-encoding: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=fm3; t=1753805068; x=1753891468; bh=p+a7rYmjWTUvxfbk5QMKb CkOsPkHXRDrq74OkcXFc/w=; b=DVpUDZ/WGiDbcFXhsrktHOKRvgXKYoVTEn/EJ 9tkadPp0Mk/PjsTHt/RtgCwVvLRXayf5xJrUSA43YUpYMDFSEWQb3ESjVoG8k//y sM5sFICgTOo1lamt+9fW7QLcvs/SCZy1i5DtAhQ1L2o71no3IhL5gtVERhwAcDTn UfKD04SuqSrAhMYSU3dK2Ob+1+XVDkQvk+Kwjah+HB9HULR9Q05n4izD9licsp19 usICGHGf5JEuK/Gi1I6juQ6PsFRAWuOTooEBvdxfYxPJ/hHbskbhPp6h1pyzxoNn UVgo+R6VUfwpC6RRjKrL/Gtg6AHoozpvtpEz1kNAhvfYHaf0Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding: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-sender :x-me-sender:x-sasl-enc; s=fm3; t=1753805068; x=1753891468; bh=p +a7rYmjWTUvxfbk5QMKbCkOsPkHXRDrq74OkcXFc/w=; b=UAt3Zv3l3RHYpNjpc Lww+SNzf9oClVjZ3AMtyEtIkKF0wQ1/5tjtkoy6AVKXZ+vrGNc44Rxo03wQ3BVcX vQjsaWeFZ+u63tE94lhqQfIGOPBqHDAy1keuFy7psYoLChW7ob51fGkM6lLEiTG0 Js6dP3yloffrI1lnrLoqzKFhxZqn23J2vzTdQp3fT6UhE/PVhABWH23P2lFsVq8K Nn+WE1Ts/0xIybRvZ9n9aDASaGKEBeaBsD+grPX8JMw9vDmREe85IGfqHgG7l1M2 8w9AmeTKgdvTDJGAmniYidZa2Qr7GjxoC8CttZ1GRopXHXLh6ZrrrbpSegjLQfuY lx89A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdelheegkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpefoggffhffvkfgjfhfutgfgsehtjeertdertddtnecuhfhrohhmpedfnfgrrhhrhicu ifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomheqne cuggftrfgrthhtvghrnhepueevvdduhffffffhleeuhedvjeevgfelgeetgefftedufeel heegfedvheegleetnecuffhomhgrihhnpehphhhprdhnvghtnecuvehluhhsthgvrhfuih iivgeptdenucfrrghrrghmpehmrghilhhfrhhomheplhgrrhhrhiesghgrrhhfihgvlhgu thgvtghhrdgtohhmpdhnsggprhgtphhtthhopedupdhmohguvgepshhmthhpohhuthdprh gtphhtthhopehinhhtvghrnhgrlhhssehlihhsthhsrdhphhhprdhnvght X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 0107E700065; Tue, 29 Jul 2025 12:04:27 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 X-ThreadId: Te93880ab4bf8e5d1 Date: Tue, 29 Jul 2025 11:04:06 -0500 To: "php internals" Message-ID: In-Reply-To: References: Subject: Re: [PHP-DEV] [RFC] Add "is_representable_as_float()" and "is_representable_as_int()" functions Content-Type: text/plain Content-Transfer-Encoding: 7bit From: larry@garfieldtech.com ("Larry Garfield") On Tue, Jul 29, 2025, at 7:52 AM, Alexandre Daubois wrote: > Hi internals, > > I would like to present the RFC to add the > "is_representable_as_float()" and "is_representable_as_int()" > functions. These functions provide developers with a way to check > whether values can be losslessly converted between integer and > floating-point representations. > > https://wiki.php.net/rfc/is-representable-as-float-int > > Best, > Alexandre Daubois This looks lovely. Since only int, float, and string can ever be true, does it make sense to type the function parameters as `int|float|string` rather than `mixed`, to automatically exclude arrays, objects, and null? (All of which would always be false.) (I could probably argue either way on it, but my first inclination is yes; push the initial validation upstream. You should always know if a variable is a primitive or not, at the very least.) --Larry Garfield