Re: PHP_FLOAT_MIN is positive
| From: | Michael Wallner | Date: | Wed, 03 Apr 2019 11:50:25 +0000 |
| Subject: | Re: PHP_FLOAT_MIN is positive | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-105040@lists.php.net to get a copy of this message | ||
On 03/04/2019 12:27, Diogo Neves wrote:
> It really don't make much sense:
>
> <?php
>
> var_dump( PHP_FLOAT_MIN < 0 );
> var_dump( PHP_INT_MIN < 0 );
>
> On Wed, Apr 3, 2019 at 10:52 AM Benjamin Morel <benjamin.morel@gmail.com>
> wrote:
>
>> Hi internals,
>>
>> I just used PHP_FLOAT_MIN for the first time, and was surprised that it is
>> the smallest **positive** number representable. Is this expected?
>>
>> This is unlike PHP_INT_MIN, which is the absolute smallest representable
>> integer, and as such is negative:
>>
>> echo PHP_INT_MIN; // -9223372036854775808
>> echo PHP_FLOAT_MIN; // 2.2250738585072E-308
>>
>> If it is intended, maybe the doc
>>
>> <https://www.php.net/manual/en/reserved.constants.php> should
>> be clear
>> about this, at the moment it is just:
>>
>> Smallest representable floating point number.
>>
>>
>> Which is confusing IMO.
FLT_MIN is the smallest real near 0. Are you looking for -FLT_MAX?
With IEEE754 floats, there are positive and negative zeros, so the range
above and below 0 is the same.
--
Regards,
Mike
Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc
Attachment: [application/pgp-signature] OpenPGP digital signature signature.asc