How to check if two integers have opposite signs in Go

1 Answer

0 votes
package main

import (
    "fmt"
)

func main() {
    x, y := 3, -9
    b := (x ^ y) < 0
    fmt.Println(b)

    x, y = 5, 6
    b = (x ^ y) < 0
    fmt.Println(b)
}



/*
run:

true
false

*/

 



answered Jul 24, 2025 by avibootz

Related questions

...