Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128234 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 EB2401A00BC for ; Sat, 26 Jul 2025 06:13:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1753510316; bh=moxgpoA8W5oELLWv7ais1HJhsVFxveyYmoEVkz5920c=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=mrZN9nWBE3BKrgH4kx5kA4xu0uYx5f2Nafem8UVgg/amUW2rThwF9HOeNijBmzAqx L3S+hsS1yxZmEZpFRI1DlIet/xF6fT3dkDcOIx8ApacNChRg68YNyPKfyJ7t+ewvfi UncbzVgA8GDHJZt0sDeom9NNutJFZaZlCmaWeuwS8xwu0ehiDid0smMSDF/S+FUWjp JVWd8NkOF/Zx52U1KkaBJpXem1eddWaK+h2jpJa9ZYcBdhMbt/77EOioEreFq2hxrN 9Z528VRQEdujcecDb90hw3k8yULwLHxEkTIP8PcdUByHqshqOxpaUdEIOV9enVzk66 x8wHRLYNhUS9w== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 0F854180074 for ; Sat, 26 Jul 2025 06:11:56 +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=-0.4 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS 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 mail-ed1-f48.google.com (mail-ed1-f48.google.com [209.85.208.48]) (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 ; Sat, 26 Jul 2025 06:11:55 +0000 (UTC) Received: by mail-ed1-f48.google.com with SMTP id 4fb4d7f45d1cf-60c01f70092so4396442a12.3 for ; Fri, 25 Jul 2025 23:13:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753510418; x=1754115218; darn=lists.php.net; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=moxgpoA8W5oELLWv7ais1HJhsVFxveyYmoEVkz5920c=; b=BUImxVUFGtOQcuJod+yhwi/7yLx6yXxEptdJeVWGRP6+JfoguGqH2wiJKPcRtj6APK hYbj6x4Mc6LL1zfA0y0XGvUTUbjO6Z39p+j0jvxg+SQw+3IJP9GkDJKDBNb/AuYjwEQ9 OEOeZ/Ot3SU3yvSYqTGEd+5nFoYaJq2mJJF7DCV51+8WYv25j0Fbf0TvmlJ/dj+P8zgi GgwBTja6On3rDyQ2bxlJFjfu3OykiaXMNKPO3zUV4vPU0QHezQlyyiLJ3+pTg7RJ0DrI ZpHs/GSeXlUwNa1WDg4DXj9+W28A8Eso2LQgsq+YjEPjB5CU1LlHLA9SQLF+9L/WuoCu +GRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753510418; x=1754115218; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=moxgpoA8W5oELLWv7ais1HJhsVFxveyYmoEVkz5920c=; b=Hhdt8XOw3ods5UzEfLk9sP5OcrV8zJIhY0slGlwUn8a7rn5bR8TSsN/1lyX3JyfWGY T4RqZ0kx7esyJeZPNQuhjoALb+89Iw0z20fAE7AkSWmMNEWYu9Z6XJaoPntiww38x2f/ dU50Qbmztp+ib8U02B7EGpqRnHJ47oGWJR6nau6yDOlJi/Fz8GayyULZ99i8hjjCG7K9 a4jxDK8s98xBS/jbQvAWMGlNAnFzF1+FuqWEpAze4TqKXBEnzv4Hcs0iWbBp/wNAr1Yh 9nA+Dh+vDpQaAjbenJqodnysoFxNsdIFIRbXVufN6yhoun/1WgkICJV2CR+dE82slmma wFMQ== X-Gm-Message-State: AOJu0Yxmt8Ay1aIhMAxV338mPE20oDpbfwON/9yBAIUW/gKBP/U70uQu HhKo7BmvTBUfPFBrEbJlJoE2gMfZoXawZDFz6n/pEkBE14cC0goOPOvcDOWACfXhz7pJGGLvYqf mYi72NIPSJNFxtFyfvMG1z7netEyUMkLeTbfj X-Gm-Gg: ASbGnctySa7hmwuAA+LRkhLQbyNNDG9fAwDaKvpi+uvNeQmUyOJZl4y1RePmO3zaaG+ ewBB5k97gX0k2bn8EmrPJxoCAabMSj40xlGXy8Ekf/4El5OAzsW2C3TPCttgE+IqHT+PPkdiiDc 1KFbjLPyguxplTemDejmI2XpLoWkIf+nwWOoKH3nUBkQQGdxJrZiI6JZ5ygAyz34fwvBekaFCcZ OKLezgTvz+IaTec7VN0AQgmBe2/fLjpUm+xnKg2 X-Google-Smtp-Source: AGHT+IHND6799sC8ByT06VFmyAdCG0fEbcJw4+7xkR8xXhbItLcfxaElKD8XpqEaO5h9M4w06PrT9fpCHCDjdZcqwkg= X-Received: by 2002:a05:6402:51cb:b0:612:b723:4d95 with SMTP id 4fb4d7f45d1cf-614f1f2e494mr4090022a12.30.1753510418097; Fri, 25 Jul 2025 23:13:38 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Sat, 26 Jul 2025 08:13:27 +0200 X-Gm-Features: Ac12FXwNmPtsg0TwsfTbr2HqK7wxgmd9ryhYT1q4M8EfnN5kBob9WKiLD2Cl8-4 Message-ID: Subject: Re: [PHP-DEV] [DISCUSSION] Adding the "is_integer_safe()" function To: "Rowan Tommins [IMSoP]" Cc: PHP internals list Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: alex.daubois+php@gmail.com (Alexandre Daubois) Hello Rowan, Le ven. 25 juil. 2025 =C3=A0 23:10, Rowan Tommins [IMSoP] a =C3=A9crit : > 1) You need to flesh out your proposal to be explicit about *what* it wou= ld do, as well as why. Indeed, I was too focused on the why and I forgot the most important part. The idea is to have a function that receives an integer or a float and returns bool if the provided argument is inside the safe Javascript integer interval, namely [-(2^53)+1 ; (2^53)-1]. It's signature would be `is_integer_safe(int|float $num): bool`. This interval is considered safe because the floating-point mantissa is stored on 52 bits. This is nicely described in MDN [1]. > 2) The function needs a better name, to avoid confusion over what "safe" = means. I agree with you. I haven't come up with a better name yet as this one could be ambiguous. Best, Alex [1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Globa= l_Objects/Number/MAX_SAFE_INTEGER#description