Returns an int value with at most a single one-bit, in the position of the lowest-order ("rightmost") one-bit in the specified int value. Returns zero if the specified value has no one-bits in its two's complement binary representation, that is, if it is equal to zero.

Program:

package com.candidjava;
public class IntegerLowestOneBit
{
public static void main(String[] args)
{
int value = 178;
// Get the binary equivalent
System.out.println("Binary equivalent:"+Integer.toBinaryString(value));
// get the integer equivalent of the lowest one's bit
System.out.println("Lowest one's bit equivalent:"+Integer.lowestOneBit(value));
}
}

Output;

Binary equivalent:10110010

Lowest one's bit equivalent:2

Description:

The lowestOneBit(int i) method simply returns an int value with at most a single one-bit, in the position of the lowest-order (?rightmost?) one-bit in the specified int value. Returns zero if the specified value has no one-bits in its two?s complement binary representation, that is, if it is equal to zero.

Parameters:

i - the value whose lowest one bit is to be computed

Returns:

an int value with a single one-bit, in the position of the lowest-order one-bit in the specified value, or zero if the specified value is itself equal to zero.