示例#1
0
 public static void to_Float(ref MyFloat res, ref BigInteger x)
 {
     res.x = x;
     //res.e = 1024;
     res.e = prec;
     res.normalize();
 }
示例#2
0
        public void sub(ref MyFloat res, ref MyFloat op1, ref MyFloat op2)
        {
            int d = op1.e - op2.e;

            if (d >= 0)
            {
                res.x = op1.x.Subtract((op2.x.ShiftRight(d)));
                res.e = op1.e;
            }
            else
            {
                res.x = (op1.x.ShiftRight(-d)).Subtract(op1.x);
                res.e = op2.e;
            }
            res.normalize();
        }
示例#3
0
        public static void add(ref MyFloat res, ref MyFloat op1, ref MyFloat op2)
        {
            int d = op1.e - op2.e;

            if (d >= 0)
            {
                res.x = op1.x.Add((op2.x.ShiftRight(d)));
                res.e = op1.e;
            }
            else
            {
                res.x = (op1.x.ShiftRight(-d)).Add(op2.x);
                res.e = op2.e;
            }
            res.normalize();
        }
示例#4
0
 public static void div(ref MyFloat res, ref MyFloat op1, ref MyFloat op2)
 {
     res.x = (op1.x.ShiftLeft(prec)).Divide(op2.x);
     res.e = op1.e - op2.e;
     res.normalize();
 }
示例#5
0
 public static void mul(ref MyFloat res, ref MyFloat op1, ref MyFloat op2)
 {
     res.x = op1.x.Multiply(op2.x);
     res.e = op1.e + op2.e - prec;
     res.normalize();
 }