-
Notifications
You must be signed in to change notification settings - Fork 21
The value of floatToRawIntBits(0.0f/0.0f) is different on x86_64 and aarch64 #11632
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
Sorry, missed the info: Scala version 2.12.8 |
@dwijnand Would you confirm this? Thank you. |
I'm confused. The bytecode is the same but the result is different.
|
Using java on the two platforms, the results are same: on aarch64public class javaTest on x86_64root@donotdel-openlab-allinone-l00242678: |
NaN values can have different binary representations: $ scala scala> java.lang.Float.isNaN(Float.NaN) scala> java.lang.Float.isNaN(0.0f/0.0f) |
My question is why the behaviour is different on x86_64 and aarch64 platforms for java.lang.Float.floatToRawIntBits(0.0f/0.0f)? |
https://en.wikipedia.org/wiki/IEEE_754-1985#NaN
Float has 1 bit of sign-bit and 23 bits for fraction, I think there are like 16777215 ways of representing NaN or something like that. I recently read something about someone stuffing information in that space. |
closing on the assumption this is a JVM thing and not a Scala thing per se it's not impossible there's some bug here, but in order to reopen, someone would need to demonstrate that there is a bug in Scala and not just a result that surprised you. otherwise what you have is just a question, not a bug report. questions should go on https://users.scala-lang.org, come here once you've become reasonably certain there is a bug in Scala itself |
@SethTisue OK, I will open a topic to https://users.scala-lang.org to discuss this, thanks. |
The value of floatToRawIntBits(0.0f/0.0f) is different on x86_64 and aarch64:
on x86_64
root@donotdel-openlab-allinone-l00242678:/home/ubuntu# uname -a
Linux donotdel-openlab-allinone-l00242678 4.4.0-154-generic #181-Ubuntu SMP Tue Jun 25 05:29:03 UTC
2019 x86_64 x86_64 x86_64 GNU/Linux
scala> import java.lang.Float.floatToRawIntBits
import java.lang.Float.floatToRawIntBits
scala> floatToRawIntBits(0.0f/0.0f)
res0: Int = -4194304
scala> floatToRawIntBits(Float.NaN)
res1: Int = 2143289344
on aarch64
[root@arm-huangtianhua spark]# uname -a
Linux arm-huangtianhua 4.14.0-49.el7a.aarch64 #1 SMP Tue Apr 10 17:22:26 UTC 2018 aarch64 aarch64 aarch64 GNU/Linux
scala> import java.lang.Float.floatToRawIntBits
import java.lang.Float.floatToRawIntBits
scala> floatToRawIntBits(0.0f/0.0f)
res1: Int = 2143289344
scala> floatToRawIntBits(Float.NaN)
res2: Int = 2143289344
I test it using java, and the results are same on x86_64 and aarch64, so why scala has different values between these two platforms?
The text was updated successfully, but these errors were encountered: