Go Relational Operators
Go Language - Relational operators
Relational operators compare two operands and returns a boolean value.
Example :
CODE/PROGRAM/EXAMPLE
package main
import "fmt"
func main() {
a := 45
b := 40
if(a>b){ /* Relational or comparison Operators*/
fmt.Printf("True when a is greater\n" )
}
if(b < a){
fmt.Printf("True when b is lesser\n" )
}
if(b!=a){
fmt.Printf("True when both a and b are not equal\n" )
}
b=45
if(b==a){
fmt.Printf("True when both a and b are equal\n" )
}
}
Output:
True when a is greater
True when b is lesser
True when both a and b are not equal
True when both a and b are equal
Bitwise operators :
Bitwise operators perform bit-by-bit operation and works on bits.
Example :
CODE/PROGRAM/EXAMPLE
package main
import "fmt"
func main() { /* Bitwise operators examples*/
var a uint = 10
var b uint = 4
var c uint = 2
c = a & b
fmt.Printf("Value of c is %d\n", c )
c = a | b
fmt.Printf("Value of c is %d\n", c )
c = a ^ b
fmt.Printf("Value of c is %d\n", c )
c = a << 2
fmt.Printf("Value of c is %d\n", c )
c = a >> 2
fmt.Printf("Value of c is %d\n", c )
}
Output : Value of c is 0
Value of c is 14
Value of c is 14
Value of c is 40
Value of c is 2