Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128209 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 2C3101A00BC for ; Thu, 24 Jul 2025 12:51:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1753361390; bh=uI/MbAd9D/tZJWUKdtsCoFHodwV/Mk55t39JTq0SRHk=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=gpCUsvdF04SAuhsDnT9aMgtDWux5uB00lzg1u4OiqAcuLn6XxISyXZyYoBiiadCXB Dgpk/qao/PaLjBqkuhuK3oFwOB4PSQFdqnhOmNde+eikD9nC2ugLFedi7mW8aCrGgZ gM7JGUDnk6ZMYPEeH8dGe17Sg5kArux9cc2aDBPhWRi8TzelZH+W/H4Y0GJCtVYDwA uAKUFNsIN4OOP+2fgSolietu9nUYX5NQTKyjQ+h73eH508Cm/pGa4IXvApZfdncgxu +N6p8nxbU98ivAUEJDsHKqdpdBcdsPMoBbQe0ZJdtV5Z/7XhThD3tY/4TKpTRS+g0V ZLgg+YqSgpksA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8FBC4180087 for ; Thu, 24 Jul 2025 12:49:49 +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=-1.2 required=5.0 tests=BAYES_20,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-f45.google.com (mail-ed1-f45.google.com [209.85.208.45]) (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 ; Thu, 24 Jul 2025 12:49:49 +0000 (UTC) Received: by mail-ed1-f45.google.com with SMTP id 4fb4d7f45d1cf-612b34ef0c2so2001169a12.0 for ; Thu, 24 Jul 2025 05:51:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753361492; x=1753966292; 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=uI/MbAd9D/tZJWUKdtsCoFHodwV/Mk55t39JTq0SRHk=; b=SYyAt5o9lF+EpPUnC603cdS8ir9nP8SiXflwvLiLGe0CnP4CaiRFotDxTrn+oxIdP9 qJSJomd6E5vvMsl4qU8Bu4kp8klvUtbVcLgX/ieNiPYIoJcyaj4SWXwwgVmwVdQo8nvj AiKdAqjqytL5+wfS9c1czEVZAA3eGZVGJDIc6Hzc9gBU6otigSd71EgGAlVx9Rw9bZnz 3neQgEIUSJ1xe8zibaxpeOGljdUsjI7U/ukyqZsVVaymC0eR/AeC0fpAwvSrRk/aUTxu pQvOweWzsBOv/WWb+UCC7EPlUUB86TF4g9f0r4QcBdPnYSWsnSv5uEqvcWOf4f3GoNN1 BJFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753361492; x=1753966292; 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=uI/MbAd9D/tZJWUKdtsCoFHodwV/Mk55t39JTq0SRHk=; b=i9AeOaLJiS3WVWTiR9dQdle/N9wD5ulBUI2W7e7SinOyDNQ+6+NxhfWHFJ7e6jfZC7 fk4nIoT8OxlbrLZSmRlRoK+bIULzjqqP89xl161I5QyZffIY2/TEVCYDkbMBlkW+MK6N dU4ViuMv2NtICVOtGEtuedDdW+BYMARkpYUWlYm44Z65EveF3YzL9Bi8JphEAMKEwmQG mR8n0zbHZzxxh8SBKpMVWWbksX8HraR5BjxBLNp8pzziQO66C4g0M8bZ0i5ZUYYc233B n6ze02JJdhAr6J7lKq5GlayFsHyK0S2zEbsgoA4BGMWRaflQPD6Hi73wK9Jmx3UJEMjw iZVA== X-Gm-Message-State: AOJu0Yzg3p/hfeS1OK7lSLCtSRcnkL5IDkrjjNgZkXz00rXYUi2Vxydv Np+Dp8jxMms+gHXyS/rExSHoLe0P062JL967UUAbLHZ+XXj2MxyveyPsYTd4iUKhfUH0yjomK1t nbzyQbf3k7h+7K+gkFRsKzqraXcdHcDuI8yKY X-Gm-Gg: ASbGncuGhJ0VVRXFNJTZyf6eiBYijW0RrfmFe69B4iVnnzsTXKo+7sdSbvi2Jiz7ukF U4RlXuCE1vEh5DFBl7wqb6b7Jjxhwn4ygMayuHqyfCn7HeE92lMF/wtIEO59J0xF7p1h3cSczO5 3/O4ZvUr/hhGhORFOWtvJGoDa/A174FpggZu9RwP2PyBYZSdYnWzUSKzf6nkYJxusKFVt78IrD1 K+nZqOd9xdW32k1D7YHpDn3uq4qpJr7jocMkEBJ X-Google-Smtp-Source: AGHT+IHlpjjEj2c9BVAHA+tzOd9/ujFdavxUkw27Ud4lJvl5z20atSYxF0904s26oSHD3iafeYtrDRCn42MSHPF72Zw= X-Received: by 2002:a50:d70d:0:b0:612:bfb2:386 with SMTP id 4fb4d7f45d1cf-6149b5a454bmr4778871a12.28.1753361492180; Thu, 24 Jul 2025 05:51:32 -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: Thu, 24 Jul 2025 14:51:20 +0200 X-Gm-Features: Ac12FXyvrbSNiwpe0L5RuOxJ5QraPx6hDsZUHS00CMSdUpZQBftVQGPxC3yFBTA Message-ID: Subject: Re: [PHP-DEV] Introduce PHP_INT_MAX_SAFE constant similar to JS's Number.MAX_SAFE_INTEGER constant To: "Gina P. Banyard" Cc: PHP internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: alex.daubois+php@gmail.com (Alexandre Daubois) Hi Gina, Le jeu. 24 juil. 2025 =C3=A0 14:46, Gina P. Banyard a = =C3=A9crit : > > Hello internals, > > I'm mailing the list for the bike shed of the naming of a new constant I = think we should introduce in PHP which I'm currently calling PHP_INT_MAX_SA= FE. > The purpose of this integer is to indicate what is the maximal integer va= lue that can be correctly represented by a float. > On 32 bits this is equal to PHP_INT_MAX, but on 64 bits it is 90071992547= 40991 (which is 2^(53) =E2=80=93 1) as the mantissa of a floating point num= ber is 52 bits. What about an actual function returning if an integer is safe or not? We actually ran into this lately with the JsonPath component of Symfony. I wrote a userland function for this: https://github.com/symfony/symfony/blob/d3a0df0243e1c68598fa066eaa6cd0cf39f= 256dc/src/Symfony/Component/JsonPath/JsonPathUtils.php#L243 Given the numerous interactions between PHP and JSON, I think it would be useful to have a function like "is_safe_integer()". Best, Alex