AND the to bit sets together and return the result. Neither input is
modified.

@param x first bit set
@param y second bit set
@return the AND of the two bit sets
505440
static BitSet and(BitSet x, BitSet y) {
        BitSet z = copy(x);
        z.and(y);
        return z;
    }
79185
public int indexOf(float x, float y) {
    	for (int i=0;i<points.length;i+=2) {
    		if ((points[i] == x) && (points[i+1] == y)) {
    			return i / 2;
    		}
    	}
    	
    	return -1;
    }
922321
@Override
    public boolean union(int x, int y) {
        int rx = x;
        int ry = y;
        int px = p[rx];
        int py = p[ry];
        while (px != py) {
            if (px < py) {
                if (rx == px) {
                    p[rx] = py;
                    return true;
                }
                p[rx] = py;
                rx = px;
                px = p[rx];
            } else {
                if (ry == py) {
                    p[ry] = px;
                    return true;
                }
                p[ry] = px;
                ry = py;
                py = p[ry];
            }
        }
        return false;
    }
370194
public void flip(int x, int y) {
    int offset = y * rowSize + (x / 32);
    bits[offset] ^= 1 << (x & 0x1f);
  }
588047
public static Bits divide(long numerator, long denominator, long maxBits) {
    if (maxBits <= 0) return NULL;
    if (numerator == 0) return ZERO;
    if (numerator == denominator) return ONE;
    if (numerator < denominator) {
      return ZERO.concatenate(divide(numerator * 2, denominator, maxBits - 1));
    }
    else {
      return ONE.concatenate(divide(2 * (numerator - denominator), denominator, maxBits - 1));
    }
  }
1103538
private int computeOffset(int x, int y) {
    if(y > x) {
      return computeOffset(y, x);
    }
    return ((x * (x + 1)) >> 1) + y;
  }
778092
public static double atan2(double y, double x) {
        if (x != x || y != y) {
            return Double.NaN;
        }

        if (y == 0) {
            final double result = x * y;
            final double invx = 1d / x;
            final double invy = 1d / y;

            if (invx == 0) { // X is infinite
                if (x > 0) {
                    return y; // return +/- 0.0
                } else {
                    return copySign(Math.PI, y);
                }
            }

            if (x < 0 || invx < 0) {
                if (y < 0 || invy < 0) {
                    return -Math.PI;
                } else {
                    return Math.PI;
                }
            } else {
                return result;
            }
        }

        // y cannot now be zero

        if (y == Double.POSITIVE_INFINITY) {
            if (x == Double.POSITIVE_INFINITY) {
                return Math.PI * F_1_4;
            }

            if (x == Double.NEGATIVE_INFINITY) {
                return Math.PI * F_3_4;
            }

            return Math.PI * F_1_2;
        }

        if (y == Double.NEGATIVE_INFINITY) {
            if (x == Double.POSITIVE_INFINITY) {
                return -Math.PI * F_1_4;
            }

            if (x == Double.NEGATIVE_INFINITY) {
                return -Math.PI * F_3_4;
            }

            return -Math.PI * F_1_2;
        }

        if (x == Double.POSITIVE_INFINITY) {
            if (y > 0 || 1 / y > 0) {
                return 0d;
            }

            if (y < 0 || 1 / y < 0) {
                return -0d;
            }
        }

        if (x == Double.NEGATIVE_INFINITY)
        {
            if (y > 0.0 || 1 / y > 0.0) {
                return Math.PI;
            }

            if (y < 0 || 1 / y < 0) {
                return -Math.PI;
            }
        }

        // Neither y nor x can be infinite or NAN here

        if (x == 0) {
            if (y > 0 || 1 / y > 0) {
                return Math.PI * F_1_2;
            }

            if (y < 0 || 1 / y < 0) {
                return -Math.PI * F_1_2;
            }
        }

        // Compute ratio r = y/x
        final double r = y / x;
        if (Double.isInfinite(r)) { // bypass calculations that can create NaN
            return atan(r, 0, x < 0);
        }

        double ra = doubleHighPart(r);
        double rb = r - ra;

        // Split x
        final double xa = doubleHighPart(x);
        final double xb = x - xa;

        rb += (y - ra * xa - ra * xb - rb * xa - rb * xb) / x;

        final double temp = ra + rb;
        rb = -(temp - ra - rb);
        ra = temp;

        if (ra == 0) { // Fix up the sign so atan works correctly
            ra = copySign(0d, y);
        }

        // Call atan
        final double result = atan(ra, rb, x < 0);

        return result;
    }
988399
public static int binaryLCA(int x, int y) {
		if (x == y) {
			return x;
		}
		int xor = x ^ y;
		int idx = getMaxExp(xor);
		if (idx == -1) {
			throw new UnsupportedOperationException();
		}
		return replaceBy1and0sFrom(x, idx);
	}
908732
public static UnsignedInteger64 add(UnsignedInteger64 x, UnsignedInteger64 y) {
		return new UnsignedInteger64(x.bigInt.add(y.bigInt));
	}
1084639
public static int hammingDistance(long[] x, long[] y) {
    final int lx = x.length, ly = y.length;
    final int min = (lx < ly) ? lx : ly;
    int i = 0, h = 0;
    for(; i < min; i++) {
      h += Long.bitCount(x[i] ^ y[i]);
    }
    for(; i < lx; i++) {
      h += Long.bitCount(x[i]);
    }
    for(; i < ly; i++) {
      h += Long.bitCount(y[i]);
    }
    return h;
  }
309734
public static <E> Set<E> union(final Set<? extends E> set1, final Set<? extends E> set2) {
        checkArgumentNotNull(set1, "set1");
        checkArgumentNotNull(set2, "set2");

        // Set 2 minus set 1
        final Set<E> difference = new HashSet<>(set2);
        difference.removeAll(set1);
        // Following stream does not compile on some JDKs
        // See also https://bugs.openjdk.java.net/browse/JDK-8051443
        // set2.stream().filter((e) -> !set1.contains(e)).collect(Collectors.toSet());

        return new AbstractSet<E>() {

            @Override
            public Iterator<E> iterator() {
                final Iterator<E> iterator = Iterators.concat(ImmutableList.of(set1.iterator(), difference.iterator()).iterator());
                // Remove operation is not supported by default
                return new Iterator<E>() {
                    @Override
                    public boolean hasNext() {
                        return iterator.hasNext();
                    }

                    @Override
                    public E next() {
                        return iterator.next();
                    }
                };
            }

            @Override
            public int size() {
                return set1.size() + difference.size();
            }

            @Override
            public boolean isEmpty() {
                return set1.isEmpty() && difference.isEmpty();
            }

            @Override
            public boolean contains(Object o) {
                return set1.contains(o) || difference.contains(o);
            }
        };
    }
550617
private int findFirstDifferingBit(String key1, String key2) {
        int bit = 0;

        while (keyMapper.isSet(bit, key1) == keyMapper.isSet(bit, key2)) {
            bit++;
        }
        return bit;
    }
217940
@Pure
	public static int toLEInt(int b1, int b2, int b3, int b4) {
        return ((b4 & 0xFF) << 24) + ((b3 & 0xFF) << 16) + ((b2 & 0xFF) << 8) + (b1 & 0xFF);
    }
1090450
private static final void x_to_y2(long10 t, long10 y2, long10 x) {
		sqr(t, x);
		mul_small(y2, x, 486662);
		add(t, t, y2);
		t._0++;
		mul(y2, t, x);
	}
865983
int xy2d(int n, int x, int y) {
        int[] xy = new int[2];
        int rx, ry, d = 0;
        // loop over bits not value
        for (int s = n >> 1; s != 0; s >>= 1) {
            rx = (x & s) != 0 ? 1 : 0; // todo better, perhaps 0*x or / s aka >>
            ry = (y & s) != 0 ? 1 : 0;
            d += s * s * ((3 * rx) ^ ry);
            xy[0] = x;
            xy[1] = y;
            rot(s, xy, rx, ry);
        }
        return d;
    }
1258977
public static long multiplyExact(long x, long y) {
        long r = x * y;
        long ax = Math.abs(x);
        long ay = Math.abs(y);
        if (((ax | ay) >>> 31 != 0)) {
            // Some bits greater than 2^31 that might cause overflow
            // Check the result using the divide operator
            // and check for the special case of Long.MIN_VALUE * -1
           if (((y != 0) && (r / y != x)) ||
               (x == Long.MIN_VALUE && y == -1)) {
                throw new ArithmeticException("long overflow");
            }
        }
        return r;
    }
338414
public static UnsignedInteger64 add(UnsignedInteger64 x, int y) {
		return new UnsignedInteger64(x.bigInt.add(BigInteger.valueOf(y)));
	}