2010-12-07 139 views
-3

使用的BigInteger我有这样的代码,我想将其更改为BigInteger的我怎么可以在Java

import java.util.*; 
public class Euclid { 
    long TIME; 
    long start = System.currentTimeMillis(); 
    private static final String EXCEPTION_MSG = 
     "Invalid value (%d); only positive integers are allowed. "; 

    public static int getGcd(int a, int b) 

    {//long start = System.currentTimeMillis(); 
     if (a < 0) 
     { 
      throw new IllegalArgumentException(String.format(EXCEPTION_MSG, a)); 
     } 
     else 
      if (b < 0) 
      { 
       throw new IllegalArgumentException(String.format(EXCEPTION_MSG, b)); 
      } 

     while (b != 0) 
     {    
      if (a > b) 
      { 
       a = a - b; 
      }  
      else 
      { 
       b = b - a; 
      }  
     } 
     return a; 
     //long timeTaken = System.currentTimeMillis() - start; 
    } 
} 
+1

要start`从长期改变`来的BigInteger,右? – 2010-12-07 06:04:20

回答