-
Notifications
You must be signed in to change notification settings - Fork 21
Primitive operations on Long with Float argument have different semantics from Java #11253
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
Comments
Scala Native and Scala.js (according to @sjrd) have the expected semantics like Java but it differs from Scala on the JVM. |
The code to be blamed is at https://github.com/scala/scala/blob/051e7b61cb18b7ed9593f38a4bc73b69e8199775/src/compiler/scala/tools/nsc/backend/jvm/BTypes.scala#L311-L314. It should have an additional case for |
Scalac mistakingly uses Double precision when performing primitive binary operations on Long that take a Float argument. Once this bug is fixed upstream we can conditionally enable the workaround only on affected versions.
Scalac mistakingly uses Double precision when performing primitive binary operations on Long that take a Float argument. Once this bug is fixed upstream we can conditionally enable the workaround only on affected versions.
Scalac mistakingly uses Double precision when performing primitive binary operations on Long that take a Float argument. Once this bug is fixed upstream we can conditionally enable the workaround only on affected versions.
Scalac mistakingly uses Double precision when performing primitive binary operations on Long that take a Float argument. Once this bug is fixed upstream we can conditionally enable the workaround only on affected versions.
Scalac mistakingly uses Double precision when performing primitive binary operations on Long that take a Float argument. Once this bug is fixed upstream we can conditionally enable the workaround only on affected versions.
Scala's primitive binary operations on Long that take Float (
e.g. (x: Long) % (y: Float)
) as an argument erroneously perform an operation in double precision, instead of float precision. This is inconsistent wrt Java semantics.Java code:
Java output:
Scala code:
Scala output:
Found by random test generation for Scala Native (http://github.com/densh/testgen).
The text was updated successfully, but these errors were encountered: