-
Notifications
You must be signed in to change notification settings - Fork 3.1k
bug#10781. Remove Float range and Double range [ci: last-only] #6468
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
Conversation
75eecc6 to
c883a7f
Compare
src/library/scala/math/Numeric.scala
Outdated
| } | ||
|
|
||
| // For Double and BigDecimal we offer implicit Fractional objects, but also one | ||
| // For BigDecimal we offer implicit Fractional objects, but also one |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably be singular "an implicit Fractional object" (admittedly, it wasn't grammatically correct in the first place)
src/library/scala/math/Numeric.scala
Outdated
| // logic in Numeric base trait mishandles abs(-0.0) | ||
| override def abs(x: Double): Double = math.abs(x) | ||
| } | ||
| trait DoubleIsFractional extends DoubleIsConflicted with Fractional[Double] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If DoubleAsIfIntegral is being removed, DoubleIsConflicted can probably be merged into DoubleIsFractional, as it's no longer conflicted (same for FloatIsFractional/FloatIsConflicted)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good 👍
|
This should target the 2.13.x-new-collections branch |
|
Yes, but let's just wait until the new collections are in 2.13.x - we only merge to 2.13.x-new-collections what's required to get the collections in 2.13.x. |
c883a7f to
45cee0e
Compare
|
Rebased on top of 2.13.x-new-collections branch for testing, and addressed review comments. |
|
I'm not disagreeing with @lrytz, but I think the target branch should be |
|
here's the subset diff: 2.13.x-new-collections...eed3si9n:wip/float-range |
485b2b2 to
e41fae8
Compare
|
Rebased and squashed. |
|
why remove immediately, instead of deprecate-in-2.13, remove-in-2.14? |
Deprecation is a useful tool to spread the cost of code migration targeting code base that was once in vogue, but no longer considered good, like cars without seatbelts and smoking cigarette in bars. It takes a while for all cars to catch up to the safety standards. That would be our procedure syntax and view bounds. Floating point ranges, on the other hand, are as broken as cell phones that can catch fire on their own, or car wheels coming off on highways. If someone is (somehow) using it it in 2.12, we should advise them to stop too. To quote @Ichoran in scala/collection-strawman#489 (comment):
|
|
If we remove this in 2.13.x (which is fine with me), let's deprecate it ASAP in 2.12 (we can still make it for 2.12.6). |
Ref scala/bug#10781 This is in prepration of Float range and Double range removal in 2.13.x (scala#6468).
Ref scala/bug#10781 This is in preparation for Float range and Double range removal in 2.13.x (scala#6468).
|
I had previously expressed misgivings about removal at scala/collection-strawman#489 (comment), but I think I'm happy to go along with the near-consensus that has developed on it. |
|
the deprecation PR is merged for 2.12.6. this PR needs a rebase. |
e41fae8 to
feca33c
Compare
|
@SethTisue Done. |
|
The deprecation PR merged in 2.12.x was merged into 2.13.x (#6575), meaning this PR needs another rebase. Thank you for playing Code Branches (tm) with scala/scala. |
|
Rebased on top of 2.13.x. |
Fixes scala/bug#10781 At the basis of range is an assumption that summation works reliably. Unfortunately it is not true for IEEE floating point number where numbers are stored as approximate fraction of binary numbers. Natually, Double and Float ranges are completely broken. See numbers of issues such as scala/bug#8518, scala/bug#9875, scala/bug#9874, scala/bug#8620, scala/bug#8670, and scala/bug#10759. I've attempted to fix the Double range in scala/collection-strawman#489 by faking it further using BigDecimal, but ultimately I was not able to overcome the fact that IEEE floats are not suited for ranges. This removes both Float and Double ranges, as well as the fake `Integral[T]` instances that underpin their existence.
|
should we merge this now? |
|
Thanks @eed3si9n, @NthPortal! |
|
@eed3si9n @NthPortal @SethTisue @som-snytt - What if we change the API? The whole problem is that we can't hit the endpoints accurately by specifying a step. So what if we abandon the idea of specifying a precise step? Suppose that WDYT? |
|
Bikeshed: maybe |
|
On #6803 I was going to give a shot at something like just ensuring that the Your idea of doing something mathy with a divided interval is also interesting as an extra credit question. The |
|
If we really want some |
|
Honestly, I'm not sure that such an API would be that useful, and would still expect confusion |
unused since scala#6468
Fixes scala/bug#10781
At the basis of range is an assumption that summation works reliably. Unfortunately it is not true for IEEE floating point number where numbers are stored as approximate fraction of binary numbers. Natually, Double and Float ranges are completely broken. See numbers of issues such as scala/bug#8518, scala/bug#9875, scala/bug#9874, scala/bug#8620, scala/bug#8670, and scala/bug#10759.
I've attempted to fix the Double range in scala/collection-strawman#489 by faking it further using BigDecimal, but ultimately I was not able to overcome the fact that IEEE floats are not suited for ranges.
This removes both Float and Double ranges, as well as the fake
Integral[T]instances that underpin their existence.