20 lines
324 B
Go
20 lines
324 B
Go
|
package types
|
||
|
|
||
|
// Returns 1 if b is true and 0 if false
|
||
|
func BoolToUint(b bool) uint {
|
||
|
if b {
|
||
|
return 1
|
||
|
}
|
||
|
return 0
|
||
|
}
|
||
|
|
||
|
// Reinterprets a slice of bools as a uint
|
||
|
// This method doesn't check for overflow
|
||
|
func BoolsToUint(b ...bool) uint {
|
||
|
var res uint
|
||
|
for i, v := range b {
|
||
|
res += BoolToUint(v) << i
|
||
|
}
|
||
|
return res
|
||
|
}
|