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

Wrong warning message (comparing values of types Float/Double and Number using `==' will always yield false) #5779

Closed
scabug opened this issue May 9, 2012 · 3 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented May 9, 2012

In the following example, a Float and a Double is compared with a Number. They are all equal, and == returns true.
However, the compiler gives the warning "comparing values of types Double and Number using `==' will always yield false" and this is not true!

scala> val d = (BigInt(1) << 64).toDouble
d: Double = 1.8446744073709552E19

scala> val f: Float = d.toFloat
f: Float = 1.8446744E19

scala> val n: java.lang.Number = d
n: Number = 1.8446744073709552E19

scala> d == f
res37: Boolean = true

scala> d == n
<console>:10: warning: comparing values of types Double and Number using `==' will always yield false
              d == n
                ^
res38: Boolean = true

scala> f == n
<console>:11: warning: comparing values of types Float and Number using `==' will always yield false
              f == n
                ^
res39: Boolean = true
@scabug
Copy link
Author

scabug commented May 9, 2012

Imported From: https://issues.scala-lang.org/browse/SI-5779?orig=1
Reporter: @dgruntz
Other Milestones: 2.10.0

@scabug
Copy link
Author

scabug commented May 22, 2012

@som-snytt said:
Probably this bug won't exist in some future version of Scala.

scala/scala#599

@scabug
Copy link
Author

scabug commented May 23, 2012

@som-snytt said:
adriaanm merged commit 2e7daa1

@scabug scabug closed this as completed May 23, 2012
@scabug scabug added the quickfix label Apr 7, 2017
@scabug scabug added this to the 2.10.0-M3 milestone Apr 7, 2017
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

2 participants