Example usage for java.math BigInteger byteValue

List of usage examples for java.math BigInteger byteValue

Introduction

In this page you can find the example usage for java.math BigInteger byteValue.

Prototype

public byte byteValue() 

Source Link

Document

Returns the value of the specified number as a byte .

Usage

From source file:com.github.jessemull.microflex.util.BigIntegerUtil.java

/**
 * Converts a list of BigIntegers to a list of bytes.
 * @param    List<BigInteger>    list of BigIntegers
 * @return                       list of bytes
 *///from  w  w  w  .j  a v  a  2s.  co  m
public static List<Byte> toByteList(List<BigInteger> list) {

    List<Byte> byteList = new ArrayList<Byte>();

    for (BigInteger val : list) {
        if (!OverFlowUtil.byteOverflow(val)) {
            OverFlowUtil.overflowError(val);
        }
        byteList.add(val.byteValue());
    }

    return byteList;

}

From source file:org.openhab.binding.ulux.internal.ump.messages.ActivateMessage.java

@Override
protected void addData(final ByteBuffer buffer) {
    BigInteger flags = BigInteger.valueOf(0);

    if (isActive()) {
        flags = flags.setBit(0);/*from w w w.  ja va  2 s  . c  om*/
    } else {
        flags = flags.setBit(1);
    }

    // flags
    buffer.put(flags.byteValue());

    // reserved
    buffer.put((byte) 0x00);
}

From source file:org.openhab.binding.ulux.internal.ump.messages.AudioStopMessage.java

@Override
protected void addData(final ByteBuffer buffer) {
    BigInteger flags = BigInteger.valueOf(0);

    if (stopNormal) {
        flags = flags.setBit(0);// w w w.ja va2s  .co m
    }
    if (stopAlarm) {
        flags = flags.setBit(1);
    }

    // flags
    buffer.put(flags.byteValue());

    // reserved
    buffer.put((byte) 0x00);
}

From source file:org.openvpms.component.system.common.jxpath.OpenVPMSTypeConverter.java

/**
 * Convert a {@link BigInteger} to another type
 * //from   ww w .j a va 2  s.  c o m
 * @param type
 *            the class to convert too
 * @param value
 *            the value to convert
 * @return Number
 *            the converted number of null.
 *            
 */
protected Number allocateNumber(Class type, BigInteger value) {
    if (type == Byte.class || type == byte.class) {
        return new Byte(value.byteValue());
    }
    if (type == Short.class || type == short.class) {
        return new Short(value.shortValue());
    }
    if (type == Integer.class || type == int.class) {
        return new Integer(value.intValue());
    }
    if (type == Long.class || type == long.class) {
        return new Long(value.longValue());
    }
    if (type == Float.class || type == float.class) {
        return new Float(value.floatValue());
    }
    if (type == Double.class || type == double.class) {
        return new Double(value.doubleValue());
    }
    if (type == BigDecimal.class) {
        return new BigDecimal(value);
    }
    if (type == BigInteger.class) {
        return value;
    }

    return null;
}