Integer.lowestOneBit() method in Java

To understand the concept of Integer.lowestOneBit(), let’s say we have a decimal value:

The Binary of 155 is:

The lowest one bit is at position 1, therefore the lowestOneBit() method returns a single bit with the position of the rightmost one-bit value. The value returned is int.

Example 1

Following is an example to get the position of rightmost one-bit using Integer.lowestOneBit():

Output

Example 2

Output

Example 3

If the decimal value passes is 0, the lowestOneBit() method returns 0 as in the below example:

Output

Java Program to convert a byte to hexadecimal equivalent
How to Convert binary to decimal in Java
Studyopedia Editorial Staff
contact@studyopedia.com

We work to create programming tutorials for all.

No Comments

Post A Comment

Discover more from Studyopedia

Subscribe now to keep reading and get access to the full archive.

Continue reading