for (int i = 0; i < result.length; i++)
int[] aMag = this.sign > 0 ? this.magnitude : this.add(ONE).magnitude;  int[] bMag = val.sign > 0 ? val.magnitude : val.add(ONE).magnitude;  boolean resultNeg = (sign < 0 && val.sign >= 0) || (sign >= 0 && val.sign < 0); int resultLength = Math.max(aMag.length, bMag.length); int[] resultMag = new int[resultLength];  int aStart = resultMag.length - aMag.length; int bStart = resultMag.length - bMag.length;  for (int i = 0; i < resultMag.length; ++i)
    public BigInteger xor(BigInteger val)     {        int[] result;                if (magnitude.length > val.magnitude.length)        {            result = new int[magnitude.length];        }        else        {            result = new int[val.magnitude.length];        }                for (int i = 0; i < result.length; i++)        {            int index = result.length - i - 1;                        if (magnitude.length > i)            {                result[index] = magnitude[magnitude.length - i - 1];            }            if (val.magnitude.length > i)            {                result[index] ^= val.magnitude[val.magnitude.length - i - 1];            }            else            {                result[index] ^= 0;            }        }         int resSign = 1;                if (sign < 0 || val.sign < 0)        {            resSign = -1;        }                return new BigInteger(resSign, result);    }