Skip to content
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

Interval refinement on doubles / floats allows NaNs. #620

Open
ChernikovP opened this issue Mar 11, 2019 · 0 comments
Open

Interval refinement on doubles / floats allows NaNs. #620

ChernikovP opened this issue Mar 11, 2019 · 0 comments

Comments

@ChernikovP
Copy link

scala> val d: Double Refined Interval.Closed[W.`5.0`.T, W.`15.0`.T] = Double.NaN
d: eu.timepit.refined.api.Refined[Double,eu.timepit.refined.numeric.Interval.Closed[Double(5.0),Double(15.0)]] = NaN

scala> val f: Float Refined Interval.Closed[W.`5.0f`.T, W.`15.0f`.T] = Float.NaN
f: eu.timepit.refined.api.Refined[Float,eu.timepit.refined.numeric.Interval.Closed[Float(5.0),Float(15.0)]] = NaN

The only way to avoid this currently is to add NonNaN to the equation:

scala> val d: Double Refined And[Interval.Closed[W.`5.0`.T, W.`15.0`.T], NonNaN] = Double.NaN
<console>:24: error: Right predicate of ((!(NaN < 5.0) && !(NaN > 15.0)) && (NaN != NaN)) failed: Predicate failed: (NaN != NaN).
       val d: Double Refined And[Interval.Closed[W.`5.0`.T, W.`15.0`.T], NonNaN] = Double.NaN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant