github.com/goplus/llgo@v0.8.3/cl/_testrt/mask/in.go (about)

     1  package main
     2  
     3  func main() {
     4  	println(mask(1))
     5  	println(mask_shl(127, 5))
     6  	println(mask_shl8(127, 5))
     7  	println(mask_shl8u(127, 5))
     8  	println(mask_shl8(127, 16))
     9  	println(mask_shl8u(127, 16))
    10  	println(mask_shr(127, 5))
    11  	println(mask_shr8(127, 5))
    12  	println(mask_shr8u(127, 5))
    13  	println(mask_shr8(127, 16))
    14  }
    15  
    16  func mask(x int8) int32 {
    17  	return int32(x) << 31 >> 31
    18  }
    19  
    20  func mask_shl8(x int8, y int) int8 {
    21  	return x << y
    22  }
    23  
    24  func mask_shl8u(x uint8, y int) uint8 {
    25  	return x << y
    26  }
    27  
    28  func mask_shl(x int, y int) int {
    29  	return x << y
    30  }
    31  
    32  func mask_shr8(x int8, y int) int8 {
    33  	return x >> y
    34  }
    35  
    36  func mask_shr8u(x uint8, y int) uint8 {
    37  	return x >> y
    38  }
    39  
    40  func mask_shr(x int, y int) int {
    41  	return x >> y
    42  }