English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
다음과 같은 십진수가 있습니다. 즉, 이진수100100110.
int dec = 294;
비트 연산을 수행하기 위해 그 중1비트 수량. 우리는bitCount()
이를 위해 메서드를 사용했습니다.
Integer.bitCount(dec);
다음은 주어진 Integer에서의 비트 연산을 보여주는 예제입니다.
public class Demo { public static void main(String []args) { //이진수100100110- int dec = 294; System.out.println("Count of one bits = " + Integer.bitCount(dec)); } }
출력 결과
Count of one bits = 4