Question: Supply a static method that computes the number of binary digits in a given integer. For example, Numbers.binaryDigits(20) should return 5 because 20 is 10100
Supply a static method that computes the number of binary digits in a given integer. For example,
Numbers.binaryDigits(20)
should return 5 because 20 is 101002.
public class Numbers { /** Returns the number of digits in the binary representation of a number @param n a nonnegative number @return the number of binary digits needed to represent n */ // TODO: supply the method . . . public static void main(String[] args) { System.out.println(Numbers.binaryDigits(20)); } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
