How to check if two integers have opposite signs in Rust

1 Answer

0 votes
fn main() {
    let mut x = 3;
    let mut y = -9;
    let b = (x ^ y) < 0;
    println!("{}", b);

    x = 5;
    y = 6;
    let b = (x ^ y) < 0;
    println!("{}", b);
}


    
/*
run:

true
false
   
*/
  

 



answered Jul 24, 2025 by avibootz

Related questions

...