**
* Returns the result of flipping the
specified bit.
*
* <p>
* A bit is the digit used in the binary
number system. A bit
* can have a value of zero or one (with no
other value allowed).
* Flipping a bit changes the value of the
bit to the other value;
* flipping a bit that is zero changes it
to one, and flipping
* a bit that is one changes it to
zero.
*
* @param x a bit
* @return the flipped value of x
* @throws BadBitException
* if x
is not a bit (has a value that is not zero and not one).
*/
public static int flipBit(int x) {
return 0;
}
/** * Returns the result of flipping the specified bit. * * <p> * A bit is the digit used in the binary number system. A bit * can have a value of zero or one (with no other value allowed). * Flipping a bit changes the value of the bit to the other value; * flipping a bit that is zero changes it to one, and flipping * a bit that is one changes it to zero. * * @param x a bit * @return the flipped value of x * @throws BadBitException if x is not a bit (has a value that is not zero and not one). */ public static int flipBit(int x) { if (x == 0) { return 1; } else if (x == 1) { return 0; } else { throw new BadBitException(); } }
Get Answers For Free
Most questions answered within 1 hours.