private void Sub(BigUInt <N> v) { for (int dig = 0; dig < Length; dig++) { CarrySub(dig, v[dig]); } }
public static BigUInt <N> Add(BigUInt <N> v1, BigUInt <N> v2) { BigUInt <N> ret = v1.Copy(); ret.Add(v2); return(ret); }
public static BigUInt <N> Sub(BigUInt <N> v1, BigUInt <N> v2) { BigUInt <N> ret = v1.Copy(); ret.Sub(v2); return(ret); }
public static BigUInt <N> Add(BigUInt <N> v1, UInt32 v2) { BigUInt <N> ret = v1.Copy(); ret.CarryAdd(0, v2); return(ret); }
public static BigUInt <N> RightBlockShift(BigUInt <N> n, int sft) { BigUInt <N> ret = n.Copy(); ret.RightBlockShift(sft); return(ret); }
public static BigUInt <N> LeftShift(BigUInt <N> n, int sft) { BigUInt <N> ret = n.Copy(); ret.LeftShift(sft); return(ret); }
public static Mantissa <N> Decimal(int digits) { if (!Consts.decimals.ContainsKey(digits)) { Consts.decimals.Add(digits, new Mantissa <N>(BigUInt <N> .Decimal(digits))); } return(Consts.decimals[digits]); }
public static Accumulator <N> Decimal(int digits) { if (!Consts.decimals.ContainsKey(digits)) { Consts.decimals.Add(digits, new Accumulator <N>(BigUInt <Double <N> > .Decimal(digits))); } return(Consts.decimals[digits]); }
public static BigUInt <N> Mul(BigUInt <N> v1, BigUInt <N> v2) { BigUInt <Double <N> > v = ExpandMul(v1, v2); if (v.Digits > Length) { throw new OverflowException(); } return(new BigUInt <N>(v.value[..Length], enable_clone: false));
public static BigUInt <N> RightRoundBlockShift(BigUInt <N> n, int sft) { BigUInt <N> ret = n.Copy(); ret.RightBlockShift(sft); if (sft >= 1 && sft <= Length && n.value[sft - 1] > UIntUtil.UInt32Round) { ret.CarryAdd(0, 1); } return(ret); }
public static BigUInt <N> RightRoundShift(BigUInt <N> n, int sft) { BigUInt <N> ret = n.Copy(); ret.RightShift(sft); if (sft >= 1 && sft <= Bits && UIntUtil.GetLSB(n.value, sft - 1) != 0) { ret.CarryAdd(0, 1); } return(ret); }
public Accumulator(Mantissa <N> n, Int64 sft = 0) { if (sft == 0) { this.value = new BigUInt <Double <N> >(n.Value, 0); } else if (sft > 0) { this.value = new BigUInt <Double <N> >(n.Value, 0) << checked ((int)sft); } else if (sft < 0 && sft > -Bits) { this.value = new BigUInt <Double <N> >(n.Value, 0) >> (int)-sft; } else { this.value = BigUInt <Double <N> > .Zero; } }
public int CompareTo([AllowNull] BigUInt <N> other) { if (other is null) { return(1); } if (this < other) { return(-1); } if (this == other) { return(0); } return(1); }
private static BigUInt <N> GenerateDecimal(int digits) { if (digits < 1) { throw new ArgumentOutOfRangeException(nameof(digits)); } UInt64 v = 1; for (int i = 0; i < digits % UIntUtil.UInt64MaxDecimalDigits; i++) { v *= 10; } BigUInt <N> uint64_maxdec = UIntUtil.UInt64MaxDecimal; BigUInt <N> biguint_dec = v; for (int i = 0; i < digits / UIntUtil.UInt64MaxDecimalDigits; i++) { biguint_dec *= uint64_maxdec; } return(biguint_dec); }
public Accumulator() { this.value = new BigUInt <Double <N> >(); }
public static Accumulator <N> Mul(Accumulator <N> v1, Accumulator <N> v2) { return(new Accumulator <N>(BigUInt <Double <N> > .Mul(v1.value, v2.value))); }
public static (Accumulator <N> div, Accumulator <N> rem) Div(Accumulator <N> v1, Accumulator <N> v2) { (BigUInt <Double <N> > div, BigUInt <Double <N> > rem) = BigUInt <Double <N> > .Div(v1.value, v2.value); return(new Accumulator <N>(div), new Accumulator <N>(rem)); }
public Accumulator(BigUInt <Double <N> > value) { this.value = value; }
public Accumulator(ReadOnlyCollection <UInt32> arr) { this.value = new BigUInt <Double <N> >(arr); }
public static int MatchBits(Mantissa <N> a, Mantissa <N> b) { return(BigUInt <N> .MatchBits(a.value, b.value)); }
public static Accumulator <N> MulShift(Accumulator <N> v1, Accumulator <N> v2) { Accumulator <N> v = new(BigUInt <Double <N> > .Mul(v1.value, v2.value)); return(RightRoundShift(v, Mantissa <N> .Bits - 1)); }
public static Mantissa <N> RoundDiv(Mantissa <N> v1, Mantissa <N> v2) { return(new Mantissa <N>(BigUInt <N> .RoundDiv(v1.value, v2.value))); }
public static (Mantissa <N> div, Mantissa <N> rem) Div(Mantissa <N> v1, Mantissa <N> v2) { (BigUInt <N> div, BigUInt <N> rem) = BigUInt <N> .Div(v1.value, v2.value); return(new Mantissa <N>(div), new Mantissa <N>(rem)); }
public static Accumulator <N> Mul(Mantissa <N> v1, Mantissa <N> v2) { return(new Accumulator <N>(BigUInt <N> .ExpandMul(v1.value, v2.value))); }
public static Mantissa <N> Sub(Mantissa <N> v1, UInt32 v2) { return(new Mantissa <N>(BigUInt <N> .Sub(v1.value, v2))); }
public static Mantissa <N> Add(Mantissa <N> v1, Mantissa <N> v2) { return(new Mantissa <N>(BigUInt <N> .Add(v1.value, v2.value))); }
public Accumulator(UInt64 v) : this() { this.value = new BigUInt <Double <N> >(v); }
public Accumulator(UInt32[] arr, bool enable_clone) { this.value = new BigUInt <Double <N> >(arr, enable_clone); }
public static int MatchBits(BigUInt <N> a, BigUInt <N> b) { return(UIntUtil.MatchBits(Length, a.value, b.value)); }
public static Accumulator <N> RoundDiv(Accumulator <N> v1, Accumulator <N> v2) { return(new Accumulator <N>(BigUInt <Double <N> > .RoundDiv(v1.value, v2.value))); }