https://kotlinlang.org logo
#python-contributors
Title
# python-contributors
s

SerVB

11/12/2021, 2:26 PM
Wow, just found an interesting test (IrPythonCodegenBoxTestGenerated$BinaryOp.testEqNullableDoubles):
Copy code
fun eq_double_any(a: Double, b: Any) = a == b

eq_double_any(0.0, -0.0)  // should be false but we in Python return true
At the same time:
Copy code
fun eq_doubleN_double(a: Double?, b: Double) = a == b

eq_doubleN_double(0.0, -0.0)  // should be true (and we return true)
mind blown
p

Piotr Krzemiński

11/12/2021, 2:46 PM
I wonder how it works for such edge cases for e. g. JVM and JS backend, if there are differences. 2 years ago I caught one difference when it comes to behavior of floating point numbers
To be frank, I'd shelve such issues for later, unless they are blockers for something more important :D
1
s

SerVB

11/12/2021, 6:17 PM
I wonder how it works for such edge cases for e. g. JVM and JS backend
I haven't checked but it seems since there is such a test, it passes on official targets. A wild guess would be that boxing can be involved 🤷
2 Views