Example #1
0
        public static Int128 FromGuid(Guid guid)
        {
            Int128 output = Zero;

            output.Value = new BigInteger(guid.ToByteArray());
            return(output);
        }
Example #2
0
 public Int128 Copy()
 {
     Int128 val = new Int128()
     {
         Value = BigInteger.Parse(this.Value.ToString())
     }; return(val);
 }
Example #3
0
        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);
        }
Example #4
0
        public static Int128 operator -(Int128 lhs, Int128 rhs)
        {
            Int128 num = lhs.Value - rhs.Value; if (num.InRange)

            {
                return(num);
            }
            else
            {
                throw new OverflowException();
            }
        }
Example #5
0
        public static Int128 operator ^(Int128 lhs, short rhs)
        {
            Int128 num = lhs.Value ^ rhs;       if (num.InRange)

            {
                return(num);
            }
            else
            {
                throw new OverflowException();
            }
        }
Example #6
0
        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);
        }
Example #7
0
        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()));
        }
Example #8
0
        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);
            }
        }
Example #9
0
 public static Int128 Pow(Int128 value, int exponent)
 {
     return(BigInteger.Pow(value.Value, exponent));
 }
Example #10
0
 public static Int128 Divide(Int128 left, Int128 right)
 {
     return(left / right);
 }
Example #11
0
 public static Int128 Multiply(Int128 left, Int128 right)
 {
     return(left * right);
 }
Example #12
0
 public static Int128 Subtract(Int128 left, Int128 right)
 {
     return(left - right);
 }
Example #13
0
 public static Int128 GrtstCmDv(Int128 left, Int128 right)
 {
     return(BigInteger.GreatestCommonDivisor(left.Value, right.Value));
 }
Example #14
0
 public static Int128 ModPow(Int128 value, Int128 exponent, Int128 modulus)
 {
     return(BigInteger.ModPow(value.Value, exponent.Value, modulus.Value));
 }
Example #15
0
 // ----------------------------------------------------------------------------------------
 //  Pass-through Methods
 // ----------------------------------------------------------------------------------------
 public static Int128 Add(Int128 left, Int128 right)
 {
     return(left + right);
 }
Example #16
0
 public static Int128 Remainder(Int128 dvdnd, Int128 dvsr)
 {
     return(BigInteger.Remainder(dvdnd.Value, dvsr.Value));
 }
Example #17
0
 public static Int128 Min(Int128 left, Int128 right)
 {
     return(BigInteger.Min(left.Value, right.Value));
 }
Example #18
0
 public static double Log10(Int128 value)
 {
     return(BigInteger.Log10(value.Value));
 }
Example #19
0
 public static int    Compare(Int128 left, Int128 right)
 {
     return(BigInteger.Compare(left.Value, right.Value));
 }
Example #20
0
 public static Int128 Abs(Int128 value)
 {
     return(BigInteger.Abs(value.Value));
 }
Example #21
0
 public static Int128 Negate(Int128 value)
 {
     return(-value);
 }