public static UIntT Decrease(UIntT value_lo, IntT value_hi, out IntT result_hi)
 {
     return(DecreaseSigned(value_lo, value_hi, out result_hi));
 }
 public static UIntT Increase(UIntT value_lo, UIntT value_hi, out UIntT result_hi)
 {
     return(IncreaseUnsigned(value_lo, value_hi, out result_hi));
 }
示例#3
0
 public static UIntT ShiftRight(UIntT low, IntT high, int count, out IntT highResult)
 {
     return(ShiftRightSigned(low, high, count, out highResult));
 }
示例#4
0
 public static UIntT ShiftRight(UIntT low, UIntT high, out UIntT highResult)
 {
     return(ShiftRightUnsigned(low, high, out highResult));
 }
示例#5
0
        public static UIntT mpn_preinv_divrem_1(Span <UIntT> q, ReadOnlySpan <UIntT> a, UIntT d_unnorm, UIntT dinv, int shift)
        {
            unchecked {
                UIntT r;
                int   i;
                UIntT d;
                var   xsize = q.Length;
                Assert(xsize >= 0);
                var size = a.Length;
                Assert(size >= 1);
                Assert(d_unnorm != 0);

#if true || ASSERTIONS_FULL
                mpn_preinv_divrem_1_assert_1(d_unnorm, dinv, shift);
#endif

                /* FIXME: What's the correct overlap rule when xsize!=0? */
                Assert(IsSameOrSeparate(q.Slice(xsize), a));

                var ahigh = a[size - 1];
                d = d_unnorm << shift;
                var q_index = (size + xsize - 1);   /* dest high limb */

                if (shift == 0)
                {
                    /* High quotient limb is 0 or 1, and skip a divide step. */
                    r = ahigh;
                    var qhigh = (r >= d ? (UIntT)1 : 0);
                    r            = (r >= d ? r - d : r);
                    q[q_index--] = qhigh;
                    size--;

                    for (i = size - 1; i >= 0; i--)
                    {
                        q[q_index] = DoubleArithmetic.BigDivRemByInverseInternal(a[i], r, dinv, d, out r);
                        q_index--;
                    }
                }
                else
                {
                    UIntT n1, n0;

                    r = 0;
                    if (ahigh < d_unnorm)
                    {
                        r            = ahigh << shift;
                        q[q_index--] = 0;
                        size--;
                        if (size == 0)
                        {
                            goto L_1;
                        }
                    }

                    n1 = a[size - 1];
                    r |= n1 >> (-shift /* sizeof(UIntT) - shift */);

                    for (i = size - 2; i >= 0; i--)
                    {
                        Assert(r < d);
                        n0         = a[i];
                        q[q_index] = DoubleArithmetic.BigDivRemByInverseInternal((n1 << shift) | (n0 >> (-shift /* sizeof(UIntT) - shift */)), r, dinv, d, out r);
                        q_index--;
                        n1 = n0;
                    }
                    q[q_index] = DoubleArithmetic.BigDivRemByInverseInternal(n1 << shift, r, dinv, d, out r);
                    q_index--;
                }

                L_1 :;
                for (i = 0; i < xsize; i++)
                {
                    q[q_index] = DoubleArithmetic.BigDivRemByInverseInternal(_: default, r, dinv, d, out r);