Source File
pmath.go
Belonging Package
github.com/gobwas/pool/internal/pmath
package pmathconst (bitsize = 32 << (^uint(0) >> 63)maxint = int(1<<(bitsize-1) - 1)maxintHeadBit = 1 << (bitsize - 2))// LogarithmicRange iterates from ceiled to power of two min to max,// calling cb on each iteration.func (, int, func(int)) {if == 0 {= 1}for := CeilToPowerOfTwo(); <= ; <<= 1 {()}}// IsPowerOfTwo reports whether given integer is a power of two.func ( int) bool {return &(-1) == 0}// Identity is identity.func ( int) int {return}// CeilToPowerOfTwo returns the least power of two integer value greater than// or equal to n.func ( int) int {if &maxintHeadBit != 0 && > maxintHeadBit {panic("argument is too large")}if <= 2 {return}--= fillBits()++return}// FloorToPowerOfTwo returns the greatest power of two integer value less than// or equal to n.func ( int) int {if <= 2 {return}= fillBits()>>= 1++return}func fillBits( int) int {|= >> 1|= >> 2|= >> 4|= >> 8|= >> 16|= >> 32return}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux 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 @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |