Nov 11, 2019

[Go] bit trick

package main
  
  func main() {
    var i = 128 // int
    m, n := byte(i), int8(i)
    println(m, -m, m == -m) // 128 128 true
    println(n, -n, n == -n) // -128 -128 true
  }

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.