How to check if two integers have opposite signs in Kotlin

1 Answer

0 votes
fun main() {
    var x = 3
    var y = -9
    var b = (x xor y) < 0
    println(b)

    x = 5
    y = 6
    b = (x xor y) < 0
    println(b)
}


 
  
/*
run:
 
true
false

*/

 



answered Jul 24, 2025 by avibootz

Related questions

...