-
Notifications
You must be signed in to change notification settings - Fork 1.7k
There is no way to check if a potentially constant double is NaN
#53614
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
Comments
If you know it's a number, you can do Also, If we had a |
It is, however, not trivial to match We could consider special-casing a constant pattern with the value of It's special-casing, which is icky, but NaN already has special-cased itself when it comes to equality, so this would just be helping the user deal with that. |
If we introduce some additional primitive members, cf. dart-lang/language#2219, then |
I had completely forgotten about this issue, thanks for bringing it up! |
Closed in favor of the existing language issue. |
According to the the IEEE-754 specification,
NaN
is never equal to any double, even toNaN
(!!). Because of this, if one wants to know if a given double isNaN
, they should use.isNaN
instead.See also #44649 and #50481, which are related to a lint to prevent comparison with
NaN
(likemyDouble == double.nan
).The problem is that we have no way to check if a potentially constant value is
NaN
.Example:
If we want to do this check we have to resign the constant constructor.
The text was updated successfully, but these errors were encountered: