public void testNegateNegative(){
  byte aBytes[]={12,56,100,-2,-76,89,45,91,3,-15,35,26,3,91};
  int aSign=-1;
  byte rBytes[]={12,56,100,-2,-76,89,45,91,3,-15,35,26,3,91};
  BigInteger aNumber=new BigInteger(aSign,aBytes);
  BigInteger result=aNumber.negate();
  byte resBytes[]=new byte[rBytes.length];
  resBytes=result.toByteArray();
  for (int i=0; i < resBytes.length; i++) {
    assertTrue(resBytes[i] == rBytes[i]);
  }
  assertTrue("incorrect sign",result.signum() == 1);
}

public void testNegateNegative ( ) { byte aBytes [ ] = { 12 , 56 , 100 , - 2 , - 76 , 89 , 45 , 91 , 3 , - 15 , 35 , 26 , 3 , 91 } ; int aSign = - 1 ; byte rBytes [ ] = { 12 , 56 , 100 , - 2 , - 76 , 89 , 45 , 91 , 3 , - 15 , 35 , 26 , 3 , 91 } ; BigInteger aNumber = new BigInteger ( aSign , aBytes ) ; BigInteger result = aNumber . negate ( ) ; byte resBytes [ ] = new byte [ rBytes . length ] ; resBytes = result . toByteArray ( ) ; for ( int i = 0 ; i < resBytes . length ; i ++ ) { assertTrue ( resBytes [ i ] == rBytes [ i ] ) ; } assertTrue ( "incorrect sign" , result . signum ( ) == 1 ) ; }
negate ( ) a negative number .
