Source File
bits.go
Belonging Package
math/bits
const deBruijn32 = 0x077CB531
var deBruijn32tab = [32]byte{
0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8,
31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9,
}
const deBruijn64 = 0x03f79d71b4ca8b09
var deBruijn64tab = [64]byte{
0, 1, 56, 2, 57, 49, 28, 3, 61, 58, 42, 50, 38, 29, 17, 4,
62, 47, 59, 36, 45, 43, 51, 22, 53, 39, 33, 30, 24, 18, 12, 5,
63, 55, 48, 27, 60, 41, 37, 16, 46, 35, 44, 21, 52, 32, 23, 11,
54, 26, 40, 15, 34, 20, 31, 10, 25, 14, 19, 9, 13, 8, 7, 6,
}
func ( uint) int {
if UintSize == 32 {
return TrailingZeros32(uint32())
}
return TrailingZeros64(uint64())
}
return int(deBruijn32tab[uint32(&-)*deBruijn32>>(32-5)])
}
return int(deBruijn32tab[(&-)*deBruijn32>>(32-5)])
}
return int(deBruijn64tab[(&-)*deBruijn64>>(64-6)])
}
func ( uint) int {
if UintSize == 32 {
return OnesCount32(uint32())
}
return OnesCount64(uint64())
}
func ( uint, int) uint {
if UintSize == 32 {
return uint(RotateLeft32(uint32(), ))
}
return uint(RotateLeft64(uint64(), ))
}
func ( uint) uint {
if UintSize == 32 {
return uint(ReverseBytes32(uint32()))
}
return uint(ReverseBytes64(uint64()))
}
= (( & ) | (( | ) &^ )) >> 63
return
}
= ((^ & ) | (^( ^ ) & )) >> 31
return
}
= ((^ & ) | (^( ^ ) & )) >> 63
return
}
func (, , uint64) (, uint64) {
const (
= 1 << 32
= - 1
)
if == 0 {
panic(divideError)
}
if <= {
panic(overflowError)
}
:= uint(LeadingZeros64())
<<=
:= >> 32
:= &
:= << | >>(64-)
:= <<
:= >> 32
:= &
:= /
:= - *
for >= || * > *+ {
--
+=
if >= {
break
}
}
:= * + - *
:= /
= - *
for >= || * > *+ {
--
+=
if >= {
break
}
}
return * + , (* + - *) >>
}
, := Div64(%, , )
return
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |