Re: PHP_FLOAT_MIN is positive
| From: | Claude Pache | Date: | Wed, 03 Apr 2019 12:34:27 +0000 |
| Subject: | Re: PHP_FLOAT_MIN is positive | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-105044@lists.php.net to get a copy of this message | ||
> Le 3 avr. 2019 à 11:51, Benjamin Morel <benjamin.morel@gmail.com> a écrit :
>
> 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.
>
> Cheers,
> Ben
And in order to avoid further confusion, the constant ought to be renamed PHP_FLOAT_MIN_POSITIVE.
Rust named it correctly: https://doc.rust-lang.org/std/f64/constant.MIN_POSITIVE.html
<https://doc.rust-lang.org/std/f64/constant.MIN_POSITIVE.html>
—Claude