Java 中的 Integer.lowestOneBit() 方法
Integer.lowestOneBit() 方法返回一個 int 值,該值最多有一個有效位,處於指定 int 值的最低位(“最右側”)。
這裡我們有一個十進位制值 294,它的二進位制是 -
100100110
最低有效位使用 Java 中的 lowestOneBit() 方法計算。
範例
public class Demo {
public static void main(String []args) {
// binary 100100110
int dec = 294;
System.out.println("Count of one bits = " + Integer.bitCount(dec));
System.out.println("Lowest one bit: " + Integer.lowestOneBit(dec));
}
}輸出
Count of one bits = 4 Lowest one bit: 2
推廣
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP