Returns the lowest bit value - Java java.lang

Java examples for java.lang:int Binary

Description

Returns the lowest bit value

Demo Code


//package com.java2s;

public class Main {
    /**//from   www . j a v a  2 s . com
     * Returns the lowest bit value
     * @param value The byte to check
     * @return 0 or 1 value of lowest bit
     */
    public static int getLowestBit(byte value) {
        return getLowestBit((int) value);
    }

    /**
     * Retruns the lowest bit value
     * @param value The int to check
     * @return 0 or 1 value of lowest bit
     */
    public static int getLowestBit(int value) {
        return (Integer.lowestOneBit(value) == 1) ? 1 : 0;
    }
}

Related Tutorials