MakeOdd() public method

public MakeOdd ( ) : int
return int
Exemplo n.º 1
0
 public static void GCD(ref BigIntegerBuilder reg1, ref BigIntegerBuilder reg2)
 {
     if (((reg1._iuLast > 0) && (reg1._rgu[0] == 0)) || ((reg2._iuLast > 0) && (reg2._rgu[0] == 0)))
     {
         int num  = reg1.MakeOdd();
         int num2 = reg2.MakeOdd();
         LehmerGcd(ref reg1, ref reg2);
         int cbit = Math.Min(num, num2);
         if (cbit > 0)
         {
             reg1.ShiftLeft(cbit);
         }
     }
     else
     {
         LehmerGcd(ref reg1, ref reg2);
     }
 }
Exemplo n.º 2
0
 public static void Gcd(ref BigIntegerBuilder reg1, ref BigIntegerBuilder reg2)
 {
     if ((reg1._iuLast <= 0 || reg1._bits[0] != 0) && (reg2._iuLast <= 0 || reg2._bits[0] != 0))
     {
         LehmerGcd(ref reg1, ref reg2);
     }
     else
     {
         var num  = reg1.MakeOdd();
         var num1 = reg2.MakeOdd();
         LehmerGcd(ref reg1, ref reg2);
         var num2 = Math.Min(num, num1);
         if (num2 > 0)
         {
             reg1.ShiftLeft(num2);
         }
     }
 }
Exemplo n.º 3
0
 public static void GCD(ref BigIntegerBuilder reg1, ref BigIntegerBuilder reg2)
 {
     // Use Lehmer's GCD, with improvements, after eliminating common powers of 2.
     if (reg1._iuLast > 0 && reg1._rgu[0] == 0 || reg2._iuLast > 0 && reg2._rgu[0] == 0)
     {
         int cbit1 = reg1.MakeOdd();
         int cbit2 = reg2.MakeOdd();
         LehmerGcd(ref reg1, ref reg2);
         int cbitMin = Math.Min(cbit1, cbit2);
         if (cbitMin > 0)
         {
             reg1.ShiftLeft(cbitMin);
         }
     }
     else
     {
         LehmerGcd(ref reg1, ref reg2);
     }
 }
Exemplo n.º 4
0
 public static void GCD(ref BigIntegerBuilder reg1, ref BigIntegerBuilder reg2) {
     if (((reg1._iuLast > 0) && (reg1._rgu[0] == 0)) || ((reg2._iuLast > 0) && (reg2._rgu[0] == 0))) {
         int num = reg1.MakeOdd();
         int num2 = reg2.MakeOdd();
         LehmerGcd(ref reg1, ref reg2);
         int cbit = Math.Min(num, num2);
         if (cbit > 0) {
             reg1.ShiftLeft(cbit);
         }
     }
     else {
         LehmerGcd(ref reg1, ref reg2);
     }
 }
Exemplo n.º 5
0
 public static void GCD(ref BigIntegerBuilder reg1, ref BigIntegerBuilder reg2) {
   // Use Lehmer's GCD, with improvements, after eliminating common powers of 2.
   if (reg1._iuLast > 0 && reg1._rgu[0] == 0 || reg2._iuLast > 0 && reg2._rgu[0] == 0) {
     int cbit1 = reg1.MakeOdd();
     int cbit2 = reg2.MakeOdd();
     LehmerGcd(ref reg1, ref reg2);
     int cbitMin = Math.Min(cbit1, cbit2);
     if (cbitMin > 0)
       reg1.ShiftLeft(cbitMin);
   }
   else
     LehmerGcd(ref reg1, ref reg2);
 }