Esempio n. 1
0
        private void _InitializeDivModResult()
        {
            m_divRes = OmgPool.GetZero();
            m_divRaw = m_divRes.Raw;

            _InitializeModResult();
        }
Esempio n. 2
0
        public static OmgNum Sqrt(OmgNum left)
        {
            if (left.IsZero())
            {
                return(OmgPool.GetZero());
            }

            if (left.IsNegative)
            {
                throw new OmgFailException("can't square root negative number");
            }

            return(_Positive(m_rooter.Sqrt(left.Raw)));
        }
Esempio n. 3
0
        public static OmgNum ToOmgNum(this string strNumber, uint _base = 10)
        {
            OmgNum result    = OmgPool.GetZero();
            RawNum rawNumber = result.Raw;

            result.IsNegative = StartsWithMinus(strNumber);

            m_converter.InputBase = _base;
            m_converter.Input     = ParseDigits(strNumber);

            m_converter.Output = rawNumber.Digits;
            m_converter.Convert();

            return(result);
        }
Esempio n. 4
0
        internal OmgNum Subtract(OmgNum left, OmgNum right)
        {
            if (left.IsNegative != right.IsNegative)
            {
                throw new OmgFailException("logic error");
            }

            m_subRes = OmgPool.GetZero();
            m_subRaw = m_subRes.Raw;

            _CalcSubtraction(left, right);

            _RemoveLeadingZeros();
            return(m_subRes);
        }
Esempio n. 5
0
        public static OmgNum ToOmgNum(this int number)
        {
            OmgNum result = OmgPool.GetZero();

            if (number == 0)
            {
                return(result);
            }

            RawNum rawNumber = result.Raw;

            result.IsNegative = number < 0;

            UInt32 absNum = (UInt32)Math.Abs(number);

            rawNumber.Digits.Add((UInt16)(absNum & ((1 << 16) - 1)));

            if ((absNum >> 16) > 0)
            {
                rawNumber.Digits.Add((UInt16)(absNum >> 16));
            }

            return(result);
        }
Esempio n. 6
0
        internal RawNum Pow(RawNum left, RawNum right, RawNum mod = null)
        {
            m_powRes = OmgPool.GetZero();

            if (left.IsZero())
            {
                return(m_powRes.Raw);
            }

            if (right.IsZero())
            {
                m_powRes.Raw.Digits.Add(1);
                return(m_powRes.Raw);
            }

            if (mod == null)
            {
                return(_MakeFastPow(new OmgNum(left), right).Raw);
            }
            else
            {
                return(_MakeFastPow(new OmgNum(left), right, new OmgNum(mod)).Raw);
            }
        }
Esempio n. 7
0
 private void _InitializeModResult()
 {
     m_modRes          = OmgPool.GetZero();
     m_modRaw          = m_modRes.Raw;
     m_modLeadingZeros = 0;
 }