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

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

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