harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r575306 - /harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math/BigInteger.java
Date Thu, 13 Sep 2007 13:19:05 GMT
Author: tellison
Date: Thu Sep 13 06:19:05 2007
New Revision: 575306

URL: http://svn.apache.org/viewvc?rev=575306&view=rev
Log:
Code tidy-up and formatting, no functional change.

Modified:
    harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math/BigInteger.java

Modified: harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math/BigInteger.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math/BigInteger.java?rev=575306&r1=575305&r2=575306&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math/BigInteger.java (original)
+++ harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math/BigInteger.java Thu
Sep 13 06:19:05 2007
@@ -28,7 +28,6 @@
 public class BigInteger extends Number implements Comparable<BigInteger>,
         Serializable {
 
-    /** @ar.org.fitc.spec_ref */
     private static final long serialVersionUID = -8287574255936472291L;
 
     /* Fields used for the internal representation. */
@@ -42,15 +41,10 @@
     /** The sign of this. */
     transient int sign;
 
-    /* Static Fields */
-
-    /** @ar.org.fitc.spec_ref */
     public static final BigInteger ONE = new BigInteger(1, 1);
 
-    /** @ar.org.fitc.spec_ref */
     public static final BigInteger TEN = new BigInteger(1, 10);
 
-    /** @ar.org.fitc.spec_ref */
     public static final BigInteger ZERO = new BigInteger(0, 0);
 
     /** The {@code BigInteger} constant -1. */
@@ -71,22 +65,18 @@
             new BigInteger(1, 6), new BigInteger(1, 7), new BigInteger(1, 8),
             new BigInteger(1, 9), TEN };
 
-    /**/
     private transient int firstNonzeroDigit = -2;
-    
+
     /* Serialized Fields */
 
-    /** @ar.org.fitc.spec_ref */
     private int signum;
 
-    /** @ar.org.fitc.spec_ref */
     private byte[] magnitude;
-    
+
     private transient int hashCode = 0;
 
     /* Public Constructors */
 
-    /** @ar.org.fitc.spec_ref */
     public BigInteger(int numBits, Random rnd) {
         if (numBits < 0) {
             // math.1B=numBits must be non-negative
@@ -109,7 +99,6 @@
         }
     }
 
-    /** @ar.org.fitc.spec_ref */
     public BigInteger(int bitLength, int certainty, Random rnd) {
         if (bitLength < 2) {
             // math.1C=bitLength < 2
@@ -121,12 +110,10 @@
         digits = me.digits;
     }
 
-    /** @ar.org.fitc.spec_ref */
     public BigInteger(String val) {
         this(val, 10);
     }
 
-    /** @ar.org.fitc.spec_ref */
     public BigInteger(String val, int radix) {
         if (val == null) {
             throw new NullPointerException();
@@ -139,10 +126,9 @@
             // math.12=Zero length BigInteger
             throw new NumberFormatException(Messages.getString("math.12")); //$NON-NLS-1$
         }
-        setFromString(this, val, radix);        
+        setFromString(this, val, radix);
     }
 
-    /** @ar.org.fitc.spec_ref */
     public BigInteger(int signum, byte[] magnitude) {
         if (magnitude == null) {
             throw new NullPointerException();
@@ -155,7 +141,8 @@
             for (byte element : magnitude) {
                 if (element != 0) {
                     // math.14=signum-magnitude mismatch
-                    throw new NumberFormatException(Messages.getString("math.14")); //$NON-NLS-1$
+                    throw new NumberFormatException(Messages
+                            .getString("math.14")); //$NON-NLS-1$
                 }
             }
         }
@@ -170,7 +157,6 @@
         }
     }
 
-    /** @ar.org.fitc.spec_ref */
     public BigInteger(byte[] val) {
         if (val.length == 0) {
             // math.12=Zero length BigInteger
@@ -188,10 +174,13 @@
 
     /* Package Constructors */
 
-    /** 
+    /**
      * Constructs a number which array is of size 1.
-     * @param sign the sign of the number
-     * @param value the only one digit of array 
+     * 
+     * @param sign
+     *            the sign of the number
+     * @param value
+     *            the only one digit of array
      */
     BigInteger(int sign, int value) {
         this.sign = sign;
@@ -199,13 +188,16 @@
         digits = new int[] { value };
     }
 
-    /** 
-     * Constructs a number without to create new space.
-     * This construct should be used only if the three fields 
-     * of representation are known. 
-     * @param sign the sign of the number
-     * @param numberLength the length of the internal array
-     * @param digits a reference of some array created before 
+    /**
+     * Constructs a number without to create new space. This construct should be
+     * used only if the three fields of representation are known.
+     * 
+     * @param sign
+     *            the sign of the number
+     * @param numberLength
+     *            the length of the internal array
+     * @param digits
+     *            a reference of some array created before
      */
     BigInteger(int sign, int numberLength, int[] digits) {
         this.sign = sign;
@@ -214,13 +206,16 @@
     }
 
     /**
-     * Creates a new {@code BigInteger} whose value is equal to the
-     * specified {@code long}.
-     * @param sign the sign of the number
-     * @param val the value of the new {@code BigInteger}.
+     * Creates a new {@code BigInteger} whose value is equal to the specified
+     * {@code long}.
+     * 
+     * @param sign
+     *            the sign of the number
+     * @param val
+     *            the value of the new {@code BigInteger}.
      */
     BigInteger(int sign, long val) {
-        //PRE: (val >= 0) && (sign >= -1) && (sign <= 1)
+        // PRE: (val >= 0) && (sign >= -1) && (sign <= 1)
         this.sign = sign;
         if ((val & 0xFFFFFFFF00000000L) == 0) {
             // It fits in one 'int'
@@ -233,11 +228,14 @@
     }
 
     /**
-     * Creates a new {@code BigInteger} with the given sign and magnitude. 
-     * This constructor does not create a copy, so any changes to the 
-     * reference will affect the new number.
-     * @param signum The sign of the number represented by {@code digits}
-     * @param digits The magnitude of the number
+     * Creates a new {@code BigInteger} with the given sign and magnitude. This
+     * constructor does not create a copy, so any changes to the reference will
+     * affect the new number.
+     * 
+     * @param signum
+     *            The sign of the number represented by {@code digits}
+     * @param digits
+     *            The magnitude of the number
      */
     BigInteger(int signum, int digits[]) {
         if (digits.length == 0) {
@@ -252,12 +250,9 @@
         }
     }
 
-    /* Public Methods */
-
-    /** @ar.org.fitc.spec_ref */
     public static BigInteger valueOf(long val) {
         if (val < 0) {
-            if(val != -1) {
+            if (val != -1) {
                 return new BigInteger(-1, -val);
             }
             return MINUS_ONE;
@@ -267,19 +262,19 @@
             return new BigInteger(1, val);
         }
     }
-    
 
-    /** @ar.org.fitc.spec_ref */
     public byte[] toByteArray() {
-        if( this.sign == 0 ){
-            return new byte[]{0};
+        if (this.sign == 0) {
+            return new byte[] { 0 };
         }
         BigInteger temp = this;
         int bitLen = bitLength();
         int iThis = getFirstNonzeroDigit();
         int bytesLen = (bitLen >> 3) + 1;
-        /* Puts the little-endian int array representing the magnitude
-         * of this BigInteger into the big-endian byte array. */
+        /*
+         * Puts the little-endian int array representing the magnitude of this
+         * BigInteger into the big-endian byte array.
+         */
         byte[] bytes = new byte[bytesLen];
         int firstByteNumber = 0;
         int highBytes;
@@ -296,23 +291,23 @@
             hB = bytesLen & 3;
             highBytes = (hB == 0) ? 4 : hB;
         }
-        
+
         digitIndex = iThis;
         bytesLen -= iThis << 2;
-        
+
         if (sign < 0) {
             digit = -temp.digits[digitIndex];
             digitIndex++;
-            if(digitIndex == numberLength){
+            if (digitIndex == numberLength) {
                 bytesInInteger = highBytes;
             }
             for (int i = 0; i < bytesInInteger; i++, digit >>= 8) {
                 bytes[--bytesLen] = (byte) digit;
             }
-            while( bytesLen > firstByteNumber ){
+            while (bytesLen > firstByteNumber) {
                 digit = ~temp.digits[digitIndex];
                 digitIndex++;
-                if(digitIndex == numberLength){
+                if (digitIndex == numberLength) {
                     bytesInInteger = highBytes;
                 }
                 for (int i = 0; i < bytesInInteger; i++, digit >>= 8) {
@@ -320,20 +315,20 @@
                 }
             }
         } else {
-        while (bytesLen > firstByteNumber) {
-            digit = temp.digits[digitIndex];
-            digitIndex++;
-            if (digitIndex == numberLength) {
-                bytesInInteger = highBytes;
-            }
-            for (int i = 0; i < bytesInInteger; i++, digit >>= 8) {
-                bytes[--bytesLen] = (byte) digit;
+            while (bytesLen > firstByteNumber) {
+                digit = temp.digits[digitIndex];
+                digitIndex++;
+                if (digitIndex == numberLength) {
+                    bytesInInteger = highBytes;
+                }
+                for (int i = 0; i < bytesInInteger; i++, digit >>= 8) {
+                    bytes[--bytesLen] = (byte) digit;
+                }
             }
         }
-        }
         return bytes;
     }
-    
+
     /** @see BigInteger#BigInteger(String, int) */
     private static void setFromString(BigInteger bi, String val, int radix) {
         int sign;
@@ -372,7 +367,7 @@
         // Parse an input string and accumulate the BigInteger's magnitude
         int digitIndex = 0; // index of digits array
         int substrEnd = startChar + ((topChars == 0) ? charsPerInt : topChars);
-        int newDigit;        
+        int newDigit;
 
         for (int substrStart = startChar; substrStart < endChar; substrStart = substrEnd,
substrEnd = substrStart
                 + charsPerInt) {
@@ -388,37 +383,30 @@
         bi.sign = sign;
         bi.numberLength = numberLength;
         bi.digits = digits;
-        bi.cutOffLeadingZeroes();        
+        bi.cutOffLeadingZeroes();
     }
 
-
-    /** @ar.org.fitc.spec_ref */
     public BigInteger abs() {
         return ((sign < 0) ? new BigInteger(1, numberLength, digits) : this);
     }
 
-    /** @ar.org.fitc.spec_ref */
     public BigInteger negate() {
         return ((sign == 0) ? this
                 : new BigInteger(-sign, numberLength, digits));
     }
 
-    /** @ar.org.fitc.spec_ref */
     public BigInteger add(BigInteger val) {
         return Elementary.add(this, val);
     }
 
-    /** @ar.org.fitc.spec_ref */
     public BigInteger subtract(BigInteger val) {
         return Elementary.subtract(this, val);
     }
 
-    /** @ar.org.fitc.spec_ref */
     public int signum() {
         return sign;
     }
 
-    /** @ar.org.fitc.spec_ref */
     public BigInteger shiftRight(int n) {
         if ((n == 0) || (sign == 0)) {
             return this;
@@ -427,7 +415,6 @@
                 this, -n));
     }
 
-    /** @ar.org.fitc.spec_ref */
     public BigInteger shiftLeft(int n) {
         if ((n == 0) || (sign == 0)) {
             return this;
@@ -436,12 +423,10 @@
                 this, -n));
     }
 
-    /** @ar.org.fitc.spec_ref */
     public int bitLength() {
         return BitLevel.bitLength(this);
     }
 
-    /** @ar.org.fitc.spec_ref */
     public boolean testBit(int n) {
         if (n == 0) {
             return ((digits[0] & 1) != 0);
@@ -455,40 +440,34 @@
             return (sign < 0);
         }
         int digit = digits[intCount];
-        int i;
         n = (1 << (n & 31)); // int with 1 set to the needed position
         if (sign < 0) {
             int firstNonZeroDigit = getFirstNonzeroDigit();
-            if (  intCount < firstNonZeroDigit  ){
+            if (intCount < firstNonZeroDigit) {
                 return false;
-            }else if( firstNonZeroDigit == intCount ){
+            } else if (firstNonZeroDigit == intCount) {
                 digit = -digit;
-            }else{
+            } else {
                 digit = ~digit;
             }
         }
         return ((digit & n) != 0);
     }
 
-    /** @ar.org.fitc.spec_ref */
     public BigInteger setBit(int n) {
-        if( !testBit( n ) ){
+        if (!testBit(n)) {
             return BitLevel.flipBit(this, n);
-        }else{
-            return this;
         }
+        return this;
     }
 
-    /** @ar.org.fitc.spec_ref */
     public BigInteger clearBit(int n) {
-        if( testBit( n ) ){
+        if (testBit(n)) {
             return BitLevel.flipBit(this, n);
-        }else{
-            return this;
         }
+        return this;
     }
 
-    /** @ar.org.fitc.spec_ref */
     public BigInteger flipBit(int n) {
         if (n < 0) {
             // math.15=Negative bit address
@@ -497,53 +476,44 @@
         return BitLevel.flipBit(this, n);
     }
 
-    /** @ar.org.fitc.spec_ref */
     public int getLowestSetBit() {
         if (sign == 0) {
             return -1;
         }
-        // (sign != 0)  implies that exists some non zero digit 
+        // (sign != 0) implies that exists some non zero digit
         int i = getFirstNonzeroDigit();
         return ((i << 5) + Integer.numberOfTrailingZeros(digits[i]));
     }
 
-    /** @ar.org.fitc.spec_ref */
     public int bitCount() {
         return BitLevel.bitCount(this);
     }
 
-    /** @ar.org.fitc.spec_ref */
     public BigInteger not() {
         return Logical.not(this);
     }
 
-    /** @ar.org.fitc.spec_ref */
     public BigInteger and(BigInteger val) {
         return Logical.and(this, val);
     }
 
-    /** @ar.org.fitc.spec_ref */
     public BigInteger or(BigInteger val) {
         return Logical.or(this, val);
     }
 
-    /** @ar.org.fitc.spec_ref */
     public BigInteger xor(BigInteger val) {
         return Logical.xor(this, val);
     }
 
-    /** @ar.org.fitc.spec_ref */
     public BigInteger andNot(BigInteger val) {
         return Logical.andNot(this, val);
     }
 
-    /** @ar.org.fitc.spec_ref */
     @Override
     public int intValue() {
         return (sign * digits[0]);
     }
 
-    /** @ar.org.fitc.spec_ref */
     @Override
     public long longValue() {
         long value = (numberLength > 1) ? (((long) digits[1]) << 32)
@@ -551,19 +521,16 @@
         return (sign * value);
     }
 
-    /** @ar.org.fitc.spec_ref */
     @Override
     public float floatValue() {
         return (float) doubleValue();
     }
 
-    /** @ar.org.fitc.spec_ref */
     @Override
     public double doubleValue() {
         return Conversion.bigInteger2Double(this);
     }
 
-    /** @ar.org.fitc.spec_ref */
     public int compareTo(BigInteger val) {
         if (sign > val.sign) {
             return GREATER;
@@ -577,69 +544,61 @@
         if (numberLength < val.numberLength) {
             return -val.sign;
         }
-        // Equal sign and equal numberLength 
+        // Equal sign and equal numberLength
         return (sign * Elementary.compareArrays(digits, val.digits,
                 numberLength));
     }
 
-    /** @ar.org.fitc.spec_ref */
     public BigInteger min(BigInteger val) {
         return ((this.compareTo(val) == LESS) ? this : val);
     }
 
-    /** @ar.org.fitc.spec_ref */
     public BigInteger max(BigInteger val) {
         return ((this.compareTo(val) == GREATER) ? this : val);
     }
 
-    /** @ar.org.fitc.spec_ref */
     @Override
     public int hashCode() {
-    	if (hashCode != 0) {
-    	    return hashCode;	
-    	}    	  
-    	for (int i = 0; i < digits.length; i ++) {
-    		hashCode = (int)(hashCode * 33 + (digits[i] & 0xffffffff));    		
-    	}  
-    	hashCode = hashCode * sign;
+        if (hashCode != 0) {
+            return hashCode;
+        }
+        for (int i = 0; i < digits.length; i++) {
+            hashCode = (hashCode * 33 + (digits[i] & 0xffffffff));
+        }
+        hashCode = hashCode * sign;
         return hashCode;
     }
 
-    /** @ar.org.fitc.spec_ref */
     @Override
     public boolean equals(Object x) {
-    	if (this == x) {
-		    return true;
-	    }
-	    if (x instanceof BigInteger) {
-		    BigInteger x1 = (BigInteger)x;            
-            return sign == x1.sign 
-                   && numberLength == x1.numberLength 
-                   && equalsArrays(x1.digits);    		
-	    }
+        if (this == x) {
+            return true;
+        }
+        if (x instanceof BigInteger) {
+            BigInteger x1 = (BigInteger) x;
+            return sign == x1.sign && numberLength == x1.numberLength
+                    && equalsArrays(x1.digits);
+        }
         return false;
-    } 
+    }
 
     boolean equalsArrays(final int[] b) {
-        int i;        
+        int i;
         for (i = numberLength - 1; (i >= 0) && (digits[i] == b[i]); i--) {
-            ;
-        }        
+            // Empty
+        }
         return i < 0;
     }
 
-    /** @ar.org.fitc.spec_ref */
     @Override
     public String toString() {
         return Conversion.toDecimalScaledString(this, 0);
     }
 
-    /** @ar.org.fitc.spec_ref */
     public String toString(int radix) {
         return Conversion.bigInteger2String(this, radix);
     }
 
-    /** @ar.org.fitc.spec_ref */
     public BigInteger gcd(BigInteger val) {
         BigInteger val1 = this.abs();
         BigInteger val2 = val.abs();
@@ -649,21 +608,19 @@
         } else if (val2.signum() == 0) {
             return val1;
         }
-        	
+
         // Optimization for small operands
         // (op2.bitLength() < 64) and (op1.bitLength() < 64)
-    	if ((( val1.numberLength == 1 )
-    			|| ( ( val1.numberLength == 2 ) && ( val1.digits[1] > 0 ) ))
-            && (val2.numberLength == 1 || (val2.numberLength == 2 && val2.digits[1]
> 0) )) {
-                return BigInteger.valueOf(Division.gcdBinary(val1.longValue(),
-                        val2.longValue()));
+        if (((val1.numberLength == 1) || ((val1.numberLength == 2) && (val1.digits[1]
> 0)))
+                && (val2.numberLength == 1 || (val2.numberLength == 2 &&
val2.digits[1] > 0))) {
+            return BigInteger.valueOf(Division.gcdBinary(val1.longValue(), val2
+                    .longValue()));
         }
-    	
+
         return Division.gcdBinary(val1.copy(), val2.copy());
-    
+
     }
 
-    /** @ar.org.fitc.spec_ref */
     public BigInteger multiply(BigInteger val) {
         // This let us to throw NullPointerException when val == null
         if (val.sign == 0) {
@@ -700,7 +657,6 @@
         return Multiplication.pow(this, exp);
     }
 
-    /** @ar.org.fitc.spec_ref */
     public BigInteger[] divideAndRemainder(BigInteger divisor) {
         int divisorSign = divisor.sign;
         if (divisorSign == 0) {
@@ -726,9 +682,8 @@
         int remainderLength = divisorLen;
         int quotientSign = ((thisSign == divisorSign) ? 1 : -1);
         int quotientDigits[] = new int[quotientLength];
-        int remainderDigits[] = Division.divide(quotientDigits,
-                quotientLength, thisDigits, thisLen, divisorDigits,
-                divisorLen);
+        int remainderDigits[] = Division.divide(quotientDigits, quotientLength,
+                thisDigits, thisLen, divisorDigits, divisorLen);
         BigInteger result0 = new BigInteger(quotientSign, quotientLength,
                 quotientDigits);
         BigInteger result1 = new BigInteger(thisSign, remainderLength,
@@ -738,7 +693,6 @@
         return new BigInteger[] { result0, result1 };
     }
 
-    /** @ar.org.fitc.spec_ref */
     public BigInteger divide(BigInteger divisor) {
         if (divisor.sign == 0) {
             // math.17=BigInteger divide by zero
@@ -759,8 +713,8 @@
             }
             return valueOf(val);
         }
-        int cmp = ((thisLen != divisorLen) ? ((thisLen > divisorLen) ? 1 : -1) : Elementary
-                .compareArrays(digits, divisor.digits, thisLen));
+        int cmp = ((thisLen != divisorLen) ? ((thisLen > divisorLen) ? 1 : -1)
+                : Elementary.compareArrays(digits, divisor.digits, thisLen));
         if (cmp == EQUALS) {
             return ((thisSign == divisorSign) ? ONE : MINUS_ONE);
         }
@@ -771,16 +725,17 @@
         int resDigits[] = new int[resLength];
         int resSign = ((thisSign == divisorSign) ? 1 : -1);
         if (divisorLen == 1) {
-            Division.divideArrayByInt(resDigits, digits, thisLen, divisor.digits[0]);
+            Division.divideArrayByInt(resDigits, digits, thisLen,
+                    divisor.digits[0]);
         } else {
-            Division.divide(resDigits, resLength, digits, thisLen, divisor.digits, divisorLen);
+            Division.divide(resDigits, resLength, digits, thisLen,
+                    divisor.digits, divisorLen);
         }
         BigInteger result = new BigInteger(resSign, resLength, resDigits);
         result.cutOffLeadingZeroes();
         return result;
     }
 
-    /** @ar.org.fitc.spec_ref */
     public BigInteger remainder(BigInteger divisor) {
         if (divisor.sign == 0) {
             // math.17=BigInteger divide by zero
@@ -807,45 +762,43 @@
         return result;
     }
 
-    /** @ar.org.fitc.spec_ref */
     public BigInteger modInverse(BigInteger m) {
         if (m.sign <= 0) {
             // math.18=BigInteger: modulus not positive
             throw new ArithmeticException(Messages.getString("math.18")); //$NON-NLS-1$
         }
         // If both are even, no inverse exists
-        if (!( testBit(0) || m.testBit(0) )) {
+        if (!(testBit(0) || m.testBit(0))) {
             // math.19=BigInteger not invertible.
             throw new ArithmeticException(Messages.getString("math.19")); //$NON-NLS-1$
         }
         if (m.isOne()) {
             return ZERO;
         }
-        
+
         // From now on: (m > 1)
         BigInteger res = Division.modInverseMontgomery(abs().mod(m), m);
         if (res.sign == 0) {
             // math.19=BigInteger not invertible.
             throw new ArithmeticException(Messages.getString("math.19")); //$NON-NLS-1$
         }
-        
-        res = ( ( sign < 0 ) ? m.subtract(res) : res );
+
+        res = ((sign < 0) ? m.subtract(res) : res);
         return res;
-        
+
     }
 
-    /** @ar.org.fitc.spec_ref */
     public BigInteger modPow(BigInteger exponent, BigInteger m) {
         if (m.sign <= 0) {
             // math.18=BigInteger: modulus not positive
             throw new ArithmeticException(Messages.getString("math.18")); //$NON-NLS-1$
         }
         BigInteger base = this;
-        
-        if(m.isOne() | ( exponent.sign>0 & base.sign == 0)){
+
+        if (m.isOne() | (exponent.sign > 0 & base.sign == 0)) {
             return BigInteger.ZERO;
         }
-        if(base.sign==0 && exponent.sign == 0){
+        if (base.sign == 0 && exponent.sign == 0) {
             return BigInteger.ONE;
         }
         if (exponent.sign < 0) {
@@ -863,7 +816,6 @@
         return res;
     }
 
-    /** @ar.org.fitc.spec_ref */
     public BigInteger mod(BigInteger m) {
         if (m.sign <= 0) {
             // math.18=BigInteger: modulus not positive
@@ -873,12 +825,10 @@
         return ((rem.sign < 0) ? rem.add(m) : rem);
     }
 
-    /** @ar.org.fitc.spec_ref */
     public boolean isProbablePrime(int certainty) {
         return Primality.isProbablePrime(abs(), certainty);
     }
 
-    /** @ar.org.fitc.spec_ref */
     public BigInteger nextProbablePrime() {
         if (sign < 0) {
             // math.1A=start < 0: {0}
@@ -887,7 +837,6 @@
         return Primality.nextProbablePrime(this);
     }
 
-    /** @ar.org.fitc.spec_ref */
     public static BigInteger probablePrime(int bitLength, Random rnd) {
         return new BigInteger(bitLength, 100, rnd);
     }
@@ -897,7 +846,7 @@
     /** Decreases {@code numberLength} if there are zero high elements. */
     final void cutOffLeadingZeroes() {
         while ((numberLength > 0) && (digits[--numberLength] == 0)) {
-            ;
+            // Empty
         }
         if (digits[numberLength++] == 0) {
             sign = 0;
@@ -932,7 +881,8 @@
     }
 
     /**
-     * Puts a big-endian byte array into a little-endian applying two complement.
+     * Puts a big-endian byte array into a little-endian applying two
+     * complement.
      */
     private void putBytesNegativeToIntegers(byte[] byteValues) {
         int bytesLen = byteValues.length;
@@ -940,15 +890,15 @@
         numberLength = (bytesLen >> 2) + ((highBytes == 0) ? 0 : 1);
         digits = new int[numberLength];
         int i = 0;
-        //Setting the sign
-        digits [numberLength -1] = -1;
+        // Setting the sign
+        digits[numberLength - 1] = -1;
         // Put bytes to the int array starting from the end of the byte array
         while (bytesLen > highBytes) {
             digits[i] = (byteValues[--bytesLen] & 0xFF)
                     | (byteValues[--bytesLen] & 0xFF) << 8
                     | (byteValues[--bytesLen] & 0xFF) << 16
                     | (byteValues[--bytesLen] & 0xFF) << 24;
-            if ( digits[i] != 0 ) {
+            if (digits[i] != 0) {
                 digits[i] = -digits[i];
                 firstNonzeroDigit = i;
                 i++;
@@ -964,14 +914,14 @@
             }
             i++;
         }
-        if( highBytes != 0 ){
+        if (highBytes != 0) {
             // Put the first bytes in the highest element of the int array
-            if ( firstNonzeroDigit != -2  ){
+            if (firstNonzeroDigit != -2) {
                 for (int j = 0; j < bytesLen; j++) {
                     digits[i] = (digits[i] << 8) | (byteValues[j] & 0xFF);
                 }
                 digits[i] = ~digits[i];
-            }else{
+            } else {
                 for (int j = 0; j < bytesLen; j++) {
                     digits[i] = (digits[i] << 8) | (byteValues[j] & 0xFF);
                 }
@@ -979,21 +929,22 @@
             }
         }
     }
-    
-    int getFirstNonzeroDigit(){
-        if( firstNonzeroDigit == -2 ){
+
+    int getFirstNonzeroDigit() {
+        if (firstNonzeroDigit == -2) {
             int i;
-            if( this.sign == 0  ){
+            if (this.sign == 0) {
                 i = -1;
-            } else{
-                for(i=0; digits[i]==0; i++)
-                    ;
+            } else {
+                for (i = 0; digits[i] == 0; i++) {
+                    // Empty
+                }
             }
             firstNonzeroDigit = i;
         }
         return firstNonzeroDigit;
     }
-    
+
     /*
      * Returns a copy of the current instance to achieve immutability
      */
@@ -1003,7 +954,6 @@
         return new BigInteger(sign, numberLength, copyDigits);
     }
 
-    /** @ar.org.fitc.spec_ref */
     private void readObject(ObjectInputStream in) throws IOException,
             ClassNotFoundException {
         in.defaultReadObject();
@@ -1012,15 +962,13 @@
         cutOffLeadingZeroes();
     }
 
-    /** @ar.org.fitc.spec_ref */
     private void writeObject(ObjectOutputStream out) throws IOException {
         signum = signum();
         magnitude = abs().toByteArray();
         out.defaultWriteObject();
     }
 
-    
-    void unCache(){
-    	firstNonzeroDigit = -2;
+    void unCache() {
+        firstNonzeroDigit = -2;
     }
 }



Mime
View raw message