Re: [RFC] Add "is_representable_as_fl oat()" and "is_represent able_as_int()" functions
| From: | Rowan Tommins [IMSoP] | Date: | Wed, 30 Jul 2025 07:30:49 +0000 |
| Subject: | Re: [RFC] Add "is_representable_as_fl oat()" and "is_represent able_as_int()" functions | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-128316@lists.php.net to get a copy of this message | ||
On 30 July 2025 07:54:11 BST, Alexandre Daubois <alex.daubois+php@gmail.com> wrote:
>>> 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 understand the thinking
>> behind this case.
>
>As the strings “INF” and “NAN” can't be cast 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.
The sentence I quoted isn't talking about string inputs, it's talking about values that
are already floats. The fact that you can't create one from a string cast doesn't seem
relevant, if you have in fact created one some other way.
https://3v4l.org/efucd
Rowan Tommins
[IMSoP]