-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Special handling for NaN #8
Comments
We could replace this: https://github.com/Richienb/proposal-math-clamp/blob/fbf4b5a1173996cfc896ebdcd6c6a3e747d79e29/spec.html#L18C6-L18C54
I don't think the rule applies to us because we intentionally define |
|
Fixed in 513523e |
Reopening to allow for discussion |
I would prefer for this to throw - but that's mostly because I wish that all operations that currently return NaN would throw instead - NaN is, after all, nothing more than a way to represent an error in a calculation, and I would rather that errors throw earlier instead of causing weird bugs later. In practice, from my understanding, it's better for operators such as division to return NaN instead of throwing an error simply because it's more performant that way (at least, that's what I've heard). But I don't know if the same argument applies to a clamping function - especially if we're considering it to throw when other arguments are NaN.. |
I think that there's definitely a potential for Math.clamp to be used in a hot path along with other math operations, which would mean that the code already has to guard against NaN, so there's no added hazard here from it. |
Not sure on details but it will likely have to be specially handled, as it should be rejected in modern proposals: https://github.com/tc39/how-we-work/blob/main/normative-conventions.md#number-taking-inputs-should-reject-nan
The text was updated successfully, but these errors were encountered: