https://kotlinlang.org logo
Title
e

elect

05/06/2019, 9:40 AM
Comparing `Float`s, I'd like to know if
==
(and also
Float.compareTo
) will call
java.lang.Float.compare()
under the hood
k

karelpeeters

05/06/2019, 9:43 AM
Look at the generated bytecode.
I'm not familiar with bytecode at all
any idea what does mean?
d

diesieben07

05/06/2019, 10:00 AM
In this case it will compare "in accordance with IEEE 754" since the
fcmp
opcode is used: https://stackoverflow.com/a/35647897/3638966
e

elect

05/06/2019, 10:01 AM
what does the
g
means? (
FCMPG
)
See the "notes" section at the end of the paragraph
e

elect

05/06/2019, 10:02 AM
yeah, thanks
d

diesieben07

05/06/2019, 10:03 AM
Not much difference, it only matters when NaN is involved
👍 1
l

Lawik

05/06/2019, 10:21 AM
Just a tip, in IntelliJ you can also do: Tools -> Kotlin -> Show Kotlin Bytcode -> click the decompile button to show Java code.
e

elect

05/06/2019, 10:21 AM
there shouldnt be a difference though, right?
l

Lawik

05/06/2019, 10:22 AM
Difference in what?
e

elect

05/06/2019, 10:22 AM
with
View-> Show Bytecode
l

Lawik

05/06/2019, 10:23 AM
No difference, the tip was more about the "decompile" button that shows Java code
e

elect

05/06/2019, 10:23 AM
ok, thanks