func (n NetworkNumber) LeastCommonBitPosition(n1 NetworkNumber) (uint, error) {
	if len(n) != len(n1) {
		return 0, ErrVersionMismatch
	}
	for i := 0; i < len(n); i++ {
		mask := uint32(1) << 31
		pos := uint(31)
		for ; mask > 0; mask >>= 1 {
			if n[i]&mask != n1[i]&mask {
				if i == 0 && pos == 31 {
					return 0, ErrNoGreatestCommonBit
				}
				return (pos + 1) + uint(BitsPerUint32)*uint(len(n)-i-1), nil
			}
			pos--
		}
	}
	return 0, nil
}
func (n NetworkNumber) LeastCommonBitPosition(n1 NetworkNumber) (uint, error) {
	if len(n) != len(n1) {
		return 0, ErrVersionMismatch
	}
	for i := 0; i < len(n); i++ {
		mask := uint32(1) << 31
		pos := uint(31)
		for ; mask > 0; mask >>= 1 {
			if n[i]&mask != n1[i]&mask {
				if i == 0 && pos == 31 {
					return 0, ErrNoGreatestCommonBit
				}
				return (pos + 1) + uint(BitsPerUint32)*uint(len(n)-i-1), nil
			}
			pos--
		}
	}
	return 0, nil
}
func ( n NetworkNumber ) LeastCommonBitPosition ( n1 NetworkNumber ) ( uint , error ) { if len ( n ) != len ( n1 ) { return 0 , ErrVersionMismatch } for i := 0 ; i < len ( n ) ; i ++ { mask := uint32 ( 1 ) << 31 pos := uint ( 31 ) for ; mask > 0 ; mask >>= 1 { if n [ i ] & mask != n1 [ i ] & mask { if i == 0 && pos == 31 { return 0 , ErrNoGreatestCommonBit } return ( pos + 1 ) + uint ( BitsPerUint32 ) * uint ( len ( n ) - i - 1 ) , nil } pos -- } } return 0 , nil }
// LeastCommonBitPosition returns the smallest position of the preceding common
// bits of the 2 network numbers, and returns an error ErrNoGreatestCommonBit
// if the two network number diverges from the first bit.
// e.g., if the network number diverges after the 1st bit, it returns 131 for
// IPv6 and 31 for IPv4 .
LeastCommonBitPosition returns the smallest position of the preceding common bits of the 2 network numbers and returns an error ErrNoGreatestCommonBit if the two network number diverges from the first bit . e . g . if the network number diverges after the 1st bit it returns 131 for IPv6 and 31 for IPv4 .