예제 #1
0
파일: myFloat.cs 프로젝트: xgalv/Cryptool2
 public static void to_Float(ref MyFloat res, ref BigInteger x)
 {
     res.x = x;
     //res.e = 1024;
     res.e = prec;
     res.normalize();
 }
예제 #2
0
파일: myFloat.cs 프로젝트: xgalv/Cryptool2
        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
파일: myFloat.cs 프로젝트: xgalv/Cryptool2
        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
파일: myFloat.cs 프로젝트: xgalv/Cryptool2
 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
파일: myFloat.cs 프로젝트: xgalv/Cryptool2
 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();
 }