private static void LehmerCore(ref BitsBuffer xBuffer,
                                       ref BitsBuffer yBuffer,
                                       long a, long b,
                                       long c, long d)
        {
            Debug.Assert(xBuffer.GetLength() >= 1);
            Debug.Assert(yBuffer.GetLength() >= 1);
            Debug.Assert(xBuffer.GetLength() >= yBuffer.GetLength());
            Debug.Assert(a <= 0x7FFFFFFF && b <= 0x7FFFFFFF);
            Debug.Assert(c <= 0x7FFFFFFF && d <= 0x7FFFFFFF);

            // Executes the combined calculation of Lehmer's step.

            uint[] x = xBuffer.GetBits();
            uint[] y = yBuffer.GetBits();

            int length = yBuffer.GetLength();

            long xCarry = 0L, yCarry = 0L;

            for (int i = 0; i < length; i++)
            {
                long xDigit = a * x[i] - b * y[i] + xCarry;
                long yDigit = d * y[i] - c * x[i] + yCarry;
                xCarry = xDigit >> 32;
                yCarry = yDigit >> 32;
                x[i]   = unchecked ((uint)xDigit);
                y[i]   = unchecked ((uint)yDigit);
            }

            xBuffer.Refresh(length);
            yBuffer.Refresh(length);
        }
        private static void LehmerCore(ref BitsBuffer xBuffer,
                                       ref BitsBuffer yBuffer,
                                       long a, long b,
                                       long c, long d)
        {
            Debug.Assert(xBuffer.GetLength() >= 1);
            Debug.Assert(yBuffer.GetLength() >= 1);
            Debug.Assert(xBuffer.GetLength() >= yBuffer.GetLength());
            Debug.Assert(a <= 0x7FFFFFFF && b <= 0x7FFFFFFF);
            Debug.Assert(c <= 0x7FFFFFFF && d <= 0x7FFFFFFF);

            // Executes the combined calculation of Lehmer's step.

            uint[] x = xBuffer.GetBits();
            uint[] y = yBuffer.GetBits();

            int length = yBuffer.GetLength();

            long xCarry = 0L, yCarry = 0L;
            for (int i = 0; i < length; i++)
            {
                long xDigit = a * x[i] - b * y[i] + xCarry;
                long yDigit = d * y[i] - c * x[i] + yCarry;
                xCarry = xDigit >> 32;
                yCarry = yDigit >> 32;
                x[i] = (uint)xDigit;
                y[i] = (uint)yDigit;
            }

            xBuffer.Refresh(length);
            yBuffer.Refresh(length);
        }