示例#1
0
            /// <summary>
            /// Overloaded left-shift operator
            /// </summary>
            /// <param name="a1"></param>
            /// <param name="shift"></param>
            /// <returns></returns>
            public static ExponentAdaptor operator <<(ExponentAdaptor a1, int shift)
            {
                if (a1.expValue == 0) return a1;

                ExponentAdaptor res = new ExponentAdaptor();
                res.expValue = a1.expValue;

                if (shift > 31)
                {
                    res.expValue = Int32.MaxValue;
                }
                else
                {
                    Int64 temp = a1.expValue;
                    temp = temp << shift;

                    if (temp > (Int64)Int32.MaxValue)
                    {
                        res.expValue = Int32.MaxValue;
                    }
                    else if (temp < (Int64)Int32.MinValue)
                    {
                        res.expValue = Int32.MinValue;
                    }
                    else
                    {
                        res.expValue = (Int32)temp;
                    }
                }

                return res;
            }
示例#2
0
            /// <summary>
            /// Overloaded division operator
            /// </summary>
            public static ExponentAdaptor operator /(ExponentAdaptor a1, ExponentAdaptor a2)
            {
                if (a1.expValue == Int32.MaxValue) return a1;

                ExponentAdaptor res = new ExponentAdaptor();
                res.expValue = a1.expValue / a2.expValue;
                return res;
            }
示例#3
0
            /// <summary>
            /// Overloaded right-shift operator
            /// </summary>
            public static ExponentAdaptor operator >>(ExponentAdaptor a1, int shift)
            {
                if (a1.expValue == Int32.MaxValue) return a1;

                ExponentAdaptor res = new ExponentAdaptor();
                res.expValue = a1.expValue >> shift;
                return res;
            }
示例#4
0
 /// <summary>
 /// Overloaded decrement operator
 /// </summary>
 public static ExponentAdaptor operator --(ExponentAdaptor adaptor)
 {
     adaptor = adaptor - 1;
     return adaptor;
 }