fthomas / fthomas/refined

Interval refinement on doubles / floats allows NaNs.

Open
#620 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Scala
Stars
1.7k
Forks
152
Avg merge
1h 20m
Merged PRs (30d)
6

Description

```scala
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
scala> val d: Double Refined And[Interval.Closed[W.`5.0`.T, W.`15.0`.T], NonNaN] = Double.NaN
: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
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.