net/ip.go
func (n NetworkNumber) Bit(position uint) (uint32, error) {
	if int(position) > len(n)*BitsPerUint32-1 {
		return 0, ErrInvalidBitPosition
	}
	idx := len(n) - 1 - int(position/BitsPerUint32)
	// Mod 31 to get array index.
	rShift := position & (BitsPerUint32 - 1)
	return (n[idx] >> rShift) & 1, nil
}
func (n NetworkNumber) Bit(position uint) (uint32, error) {
	if int(position) > len(n)*BitsPerUint32-1 {
		return 0, ErrInvalidBitPosition
	}
	idx := len(n) - 1 - int(position/BitsPerUint32)
	// Mod 31 to get array index.
	rShift := position & (BitsPerUint32 - 1)
	return (n[idx] >> rShift) & 1, nil
}
func ( n NetworkNumber ) Bit ( position uint ) ( uint32 , error ) { if int ( position ) > len ( n ) * BitsPerUint32 - 1 { return 0 , ErrInvalidBitPosition } idx := len ( n ) - 1 - int ( position / BitsPerUint32 ) // Mod 31 to get array index. rShift := position & ( BitsPerUint32 - 1 ) return ( n [ idx ] >> rShift ) & 1 , nil }
// Bit returns uint32 representing the bit value at given position, e.g.,
// "128.0.0.0" has bit value of 1 at position 31, and 0 for positions 30 to 0.
Bit returns uint32 representing the bit value at given position e . g . 128 . 0 . 0 . 0 has bit value of 1 at position 31 and 0 for positions 30 to 0 .