public static Int128 FromGuid(Guid guid) { Int128 output = Zero; output.Value = new BigInteger(guid.ToByteArray()); return(output); }
public Int128 Copy() { Int128 val = new Int128() { Value = BigInteger.Parse(this.Value.ToString()) }; return(val); }
public static Int128 DivRem(Int128 dividend, Int128 divisor, out Int128 remainder) { BigInteger rem = new BigInteger(); BigInteger.DivRem(dividend.Value, divisor.Value, out rem); remainder = rem; return(remainder); }
public static Int128 operator -(Int128 lhs, Int128 rhs) { Int128 num = lhs.Value - rhs.Value; if (num.InRange) { return(num); } else { throw new OverflowException(); } }
public static Int128 operator ^(Int128 lhs, short rhs) { Int128 num = lhs.Value ^ rhs; if (num.InRange) { return(num); } else { throw new OverflowException(); } }
public static Int128 FromEndeme(string endeme) { Int128 enCompressed = Zero; char[] cha = endeme.ToUpper().ToCharArray(); for (int i = 0; i < cha.Length; ++i) { int num = cha[i] - 65; enCompressed = enCompressed * 24 + num; } return(enCompressed); }
public string ToEndeme() { List <char> cha = new List <char>(); Int128 val = this.Copy(); while (val > 0) { Int128 rem = DivRem(val, 24, out rem); cha.Add(Convert.ToChar(rem.Value + 65)); val -= rem; val /= 24; } return(new string(cha.ToArray())); }
public static bool TryParse(string value, out Int128 result) { BigInteger num = new BigInteger(); bool ok = BigInteger.TryParse(value, out num); result = new Int128() { Value = num }; if (result.InRange) { return(ok); } else { result = new Int32(); return(false); } }
public static Int128 Pow(Int128 value, int exponent) { return(BigInteger.Pow(value.Value, exponent)); }
public static Int128 Divide(Int128 left, Int128 right) { return(left / right); }
public static Int128 Multiply(Int128 left, Int128 right) { return(left * right); }
public static Int128 Subtract(Int128 left, Int128 right) { return(left - right); }
public static Int128 GrtstCmDv(Int128 left, Int128 right) { return(BigInteger.GreatestCommonDivisor(left.Value, right.Value)); }
public static Int128 ModPow(Int128 value, Int128 exponent, Int128 modulus) { return(BigInteger.ModPow(value.Value, exponent.Value, modulus.Value)); }
// ---------------------------------------------------------------------------------------- // Pass-through Methods // ---------------------------------------------------------------------------------------- public static Int128 Add(Int128 left, Int128 right) { return(left + right); }
public static Int128 Remainder(Int128 dvdnd, Int128 dvsr) { return(BigInteger.Remainder(dvdnd.Value, dvsr.Value)); }
public static Int128 Min(Int128 left, Int128 right) { return(BigInteger.Min(left.Value, right.Value)); }
public static double Log10(Int128 value) { return(BigInteger.Log10(value.Value)); }
public static int Compare(Int128 left, Int128 right) { return(BigInteger.Compare(left.Value, right.Value)); }
public static Int128 Abs(Int128 value) { return(BigInteger.Abs(value.Value)); }
public static Int128 Negate(Int128 value) { return(-value); }