package pmath

const (
	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
	 |=  >> 32
	return 
}