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

public void testFlipBitPositiveInside2 ( ) { byte aBytes [ ] = { 1 , - 128 , 56 , 100 , - 2 , - 76 , 89 , 45 , 91 , 3 , - 15 , 35 , 26 } ; int aSign = 1 ; int number = 45 ; byte rBytes [ ] = { 1 , - 128 , 56 , 100 , - 2 , - 76 , 89 , 13 , 91 , 3 , - 15 , 35 , 26 } ; BigInteger aNumber = new BigInteger ( aSign , aBytes ) ; BigInteger result = aNumber . flipBit ( number ) ; byte resBytes [ ] = new byte [ rBytes . length ] ; resBytes = result . toByteArray ( ) ; for ( int i = 0 ; i < resBytes . length ; i ++ ) { assertTrue ( resBytes [ i ] == rBytes [ i ] ) ; } assertEquals ( "incorrect sign" , 1 , result . signum ( ) ) ; }
flipbit ( int n ) inside a positive number
