In JavaScript I see functions like:
function SomeFunc(i) {
    var f = 0x80000000;
    return Boolean(i & f);
}
What would be an analog in Golang? First of all, I see 0x80000000 is not possible, syntax is the second question
In JavaScript, coercing any non-boolean value to boolean just does a "falsiness" check; for the most part, any non-empty value is false and everything else is true. So the Go equivalent for an integer value would simply be:
return i != 0
To put it all together
package main
import (
    "fmt"
)
//function SomeFunc(i) {
//    var f = 0x80000000;
//
 //   return Boolean(i & f);
//}
func SomeFunc(i uint64) bool{
 return i & 0x80000000 != 0
}
func main() {
    fmt.Println(SomeFunc(0x800))
    fmt.Println(SomeFunc(0x81234567))
}
 Vorsprung
 VorsprungUser contributions licensed under CC BY-SA 3.0