I working on my own multiplatform binary protocol and have some common tests. When the edge cases tests failed on the JS I investigated problem and found some interesting thing. In KotlinJS Float.MIN_VALUE == Double.MIN_VALUE == Number.MIN_VALUE
and Float.MAX_VALUE == Double.MAX_VALUE == Number.MAX_VALUE
. It means that Float.MAX_VALUE
and Float.MIN_VALUE
are 64 bit values that conflict with documentation.
This is bad when your working with ArrayBuffer
and DataView
. For example:
val buff = ArrayBuffer(4)
val dv = DataView(buff)
dv.setFloat32(0, Float.MAX_VALUE)
println(dv.getFloat32(0))
prints Infinity
, that is wrong.
Max and min values are specified here kotlin/primitiveCompanionObjects.kt at master · JetBrains/kotlin · GitHub.
At the same time min and max values of Int, Short and Long are different between each other.