Question: (Java Programming) Write two Java methods: one to convert a 2's complement binary number to decimal and another to do the reverse. DO NOT use
(Java Programming) Write two Java methods: one to convert a 2's complement binary number to decimal and another to do the reverse. DO NOT use any shortcuts or predefined methods other than Math class methods. You may NOT use any data structures and must use basic array manipulation to perform the conversions. The method declarations to use are provided below. You may create private helper methods to remove any redundancy, if you wish, but the public method signatures below cannot be changed. - Accepts an anray of characters representing the bits in a two's complement number * and returns the decimal equivalent. - precondition: + This method requires that the maximun length of the parameter array is 16 . - Eparan theBits an array representing the bits in a two's complement number - ethrows I1legalargunentexception ff the length of the parameter array 16. - Preturn the decimal equivalent of the two's complement paraneter public static int convert2sconptoDecimal(final char[] theBits) f
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
