If you have a Double! and you compare it to an Int, it acts like Kotlin converts the Double! to Int first (truncating it), and then compares. Consider the following example:
Java:
public class Holder {
private Double value;
public Holder(Double value) { this.value = value; }
public Double getValue() { return value; }
}
Kotlin:
fun main(args : Array) {
val j = Holder(0.99)
println(“j.value > 0 = ${j.value > 0}”)
println(“j.value > 0.0 = ${j.value > 0.0}”)
}
This prints:
j.value > 0 = false
j.value > 0.0 = true
Is this a bug or by design?