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
Double.Range misses last element #9348
Comments
Imported From: https://issues.scala-lang.org/browse/SI-9348?orig=1 |
@axel22 said: Welcome to Scala version 2.10.4 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_21).
Type in expressions to have them evaluated.
Type :help for more information.
scala> Range.Double(0, 1, 0.7)
res0: scala.collection.immutable.NumericRange[Double] = NumericRange(0.0, 0.7) Welcome to Scala version 2.11.1 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_21).
Type in expressions to have them evaluated.
Type :help for more information.
scala> Range.Double(0.0, 1.0, 0.7)
res0: scala.collection.immutable.NumericRange[Double] = NumericRange(0.0) |
@vuakko said: Suggestion: I will add a bunch more tests for possible NumericRange pitfalls. 2.10.x seems to do num.toLong(num.quot(...)) which avoids the problem, but that was generalized away in 994de8ff. |
@adriaanm said: |
Double.Range produces wrong results, leaving out the last element whenever (end-start) == ((end-start) / step) * step in BigDecimals. Just browsing through the sources, I can't find any reason why BigDecimalAsIfIntegral.quot, DoubleAsIfIntegral.quot and FloatAsIfIntegral.quot are implemented with regular division operator / instead of BigDecimal.quot.
Bug example:
There is a related issue from 2011 at #4985
The text was updated successfully, but these errors were encountered: