Re: [RFC] clamp

From: Date: Mon, 28 Jun 2021 09:16:32 +0000
Subject: Re: [RFC] clamp
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-115167@lists.php.net to get a copy of this message
On Wed, Jun 23, 2021 at 8:43 PM Kim Hallberg <hallbergkim@gmail.com> wrote:

> Hello internals,
>
> The RFC for the clamp function is now open and under discussion, you now
> have 2 weeks
> to discuss, suggest improvements and open issues before voting is
> considered.
>
> Any and all feedback is welcomed.
>
> The RFC is available for viewing here: https://wiki.php.net/rfc/clamp <
> https://wiki.php.net/rfc/clamp>
> The implementation is available in a PR here:
> https://github.com/php/php-src/pull/7191
> <
> https://github.com/php/php-src/pull/7191>
>
> Thank you,
> Kim Hallberg
>

The RFC is missing a precise description of how this function works with
NaN and negative zero. The expected behavior is that if min or max are NaN,
an exception is thrown, if num if NaN then NaN is returned, and the
behavior wrt negative zero is unspecified. This makes for an IEEE754-2008
style clamping operation. Making negative zero smaller than positive zero
would be an IEEE754-2019 style clamp.

I'm not really convinced that this is a worthwhile addition, but also not
particularly opposed to it.

Regards,
Nikita


Thread (12 messages)

« previous php.internals (#115167) next »