Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128315 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 665B41A00BC for ; Wed, 30 Jul 2025 06:54:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1753858362; bh=7nU5a6d3OVb1EqBIVNwoW2cLUqIl1O+j64Zr+sI7Sbg=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=h7IfS0K36VDmCi95GVFThfVT6DKwWyRX0pL6F0vELC82bNKWz4kTNDtQIvVgHGhl3 yjVTFuKUbGQVgpwjbCarpPpGHayCUtEqgnoQSkQ+Yzc0tETU+YpYdYO8/WQmsrmlCq XAsJgLCptnc6BNwzX4bjYN67pfSqJOvqhqABi1AOjb/ClwLuTfbym07D16LxC+bRzF hb2OxnjvSaDXhIWRpfABrXXugVRU+Wb59zNDJiKaN7wwoCSkGwo7trP06Sz40EP+CC Q3++ffbvA5NmvsBFPwUOVyUXj9408/tH7siH/3uHaubJqlS7+4aUUy0ANL/tiQgAVV 7Nl/leJ0m4iuQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C6BC418006C for ; Wed, 30 Jul 2025 06:52:41 +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-f50.google.com (mail-ed1-f50.google.com [209.85.208.50]) (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 ; Wed, 30 Jul 2025 06:52:41 +0000 (UTC) Received: by mail-ed1-f50.google.com with SMTP id 4fb4d7f45d1cf-6157c81ff9eso1763254a12.3 for ; Tue, 29 Jul 2025 23:54:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753858463; x=1754463263; 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=7nU5a6d3OVb1EqBIVNwoW2cLUqIl1O+j64Zr+sI7Sbg=; b=BRHrwxglfbdpGKIgmLYYvmkfEUsGl1FZTnIq1esY6erQBTvlm74i3PNuedRYLedb/3 LBLOgTcQijAiBJVyY/ehu2bidr3ZuMFIPLRk13yytCi1O2YgkXjNhOU6luBtTubFkOx3 foxA0/J0Mz6quNhbabLT4iN6yNBC+67aTYIousCsYrKBnihs+JSvY3TIZ5YcAGARyO2N bOr6E2ORY03btoOcKpm5t54bhW9tca7Px06RmyM5ixzYh1ND+5/pIEb59QSw7O0T5FDO 7/J+Q9oPhPFmnt7C7uQmMjVLaGXvSmsFOVK3ofGGh+PTWKFlLvhqtiHYBuBUEclwbfjC cy5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753858463; x=1754463263; 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=7nU5a6d3OVb1EqBIVNwoW2cLUqIl1O+j64Zr+sI7Sbg=; b=H+ohobUI0GWVzUc8vd4g9QWmjxHptDZ6CDKYZIsKTHzmBochZiwMxgB905O91e0CCA ch64jXoROfHXM+nblQgX9EdrDeroK0/IGaWriYJJ4cBIptLtub0O7o+DKpQbA5sHBqe8 9EkN5jI+AsYvW6lwuaVflR2el0ExeHYTbU6V93E2XAcllo2GwNka8hBr4gcyfFvFNBQR 0hgxEoCpdWM01vUwPWqCIGVRSOXjG4d0QPdOJJMYfZnRzkZAn3aiuVWeE0zM11kXUmTa 4k4vMgOxxze/n9tCpYecrVI0bxhS7o+Ky7mrYpcvSBj4VKM53wmees0G8k2sfzuSkw5V 4Flg== X-Gm-Message-State: AOJu0YxBYtTVTLKdYWKpY7G2m2PvwC0echYcUTx+ylynm0L4rPd0h7Ld otdjDzOYP61cSUl1XUQ4WpLwPnOvMklApltHFFbw6HJ1IT4HHNtkhE4ibaQhvK9tmSCkVOPEs7n SJ1zqtb04t6LHBqACgM9B+lv5HBaj9ZjEMuzy X-Gm-Gg: ASbGnctiD5HFkZT7g/ufzHGy3BxmVo7ho50C61aM4YGi5l1V3gneVTALVq542Kj+l4k fqTt7+ztPHeiBARdfykc2qTwGP3G1Y0TUQwDGCdNkcOFWfIpaEyGvsLp1pIQ9Ff/+83Nw/F6Ooo 3y8+ZeAOblzmcMLBMIqlAItInUVKYl6qzj3iZH51LSQsqqljPkGQDAkPwwgnZuLM3JPqNa6/K7S qQ4tcoJxpQFHmzq1XQPjUV/xG8nvh2mzhe49eS2Hw== X-Google-Smtp-Source: AGHT+IEOB0GPlt7KxXWVkx/ubkqeYFWkYg6vYJk4frsq+Vsz3NcjMINSIMAs1tsfaawuJejhUVA9MPcKG+mg2LUlnWc= X-Received: by 2002:aa7:ce15:0:b0:615:6de3:9350 with SMTP id 4fb4d7f45d1cf-61586f01a9dmr1875689a12.6.1753858462692; Tue, 29 Jul 2025 23:54:22 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: <639dcf61-1b15-4381-aaff-54f0bd6bc23a@rwec.co.uk> In-Reply-To: <639dcf61-1b15-4381-aaff-54f0bd6bc23a@rwec.co.uk> Date: Wed, 30 Jul 2025 08:54:11 +0200 X-Gm-Features: Ac12FXzHBl9UQ2Oa64lXj2XF3dOP0nDQn_JwedOAgzgULC2w-7A3wmBtSAslSbA Message-ID: Subject: Re: [PHP-DEV] [RFC] Add "is_representable_as_float()" and "is_representable_as_int()" functions To: "Rowan Tommins [IMSoP]" Cc: internals@lists.php.net Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: alex.daubois+php@gmail.com (Alexandre Daubois) >> The value is a float that is not NaN or infinity > > It feels a bit odd to have a value where is_float($v) would be true, but = is_representable_as_float($v) would be false. I'd be interested to understa= nd the thinking behind this case. As the strings =E2=80=9CINF=E2=80=9D and =E2=80=9CNAN=E2=80=9D can't be cas= t as floats directly, I think it's safer to return false on these extreme values. See https://3v4l.org/TabMK#vnull for the cast example. > I suggest removing that sentence and example completely. There is nothing= the function can or should do differently on different platforms. You are right, it's misleading. I'll update the RFC accordingly. > This one is fair enough, but I'd suggest tweaking the example slightly to= avoid the same problem with different inputs: on a 64-bit build, 2**31 alr= eady is an integer, so it's trivially true. So either force a floating poin= t input: > > is_representable_as_int(2.0**31); // true on 64-bit platforms, false on 3= 2-bit platforms > > or, perhaps clearer, use an out-of-range string input: > > is_representable_as_int('2147483648'); // true on 64-bit platforms, false= on 32-bit platforms I'll also update accordingly. Thank you! Best, Alexandre Daubois