Get the leading and trailing zeros

ReturnMethodSummary
static intnumberOfLeadingZeros(int i)Returns the number of zero bits preceding the highest-order ("leftmost") one-bit
static intnumberOfTrailingZeros(int i)Returns the number of zero bits following the lowest-order ("rightmost") one-bit

public class Main {
  public static void main(String[] args) {

    System.out.println(Integer.numberOfLeadingZeros(10));
  }
}

The output:


28
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.