Example usage for java.math BigInteger shortValue

List of usage examples for java.math BigInteger shortValue

Introduction

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

Prototype

public short shortValue() 

Source Link

Document

Returns the value of the specified number as a short .

Usage

From source file:com.google.wolff.androidhunt.Hunt.java

/** Returns the singleton hunt object, and initializes it if it's not ready. */
public static Hunt getHunt(Resources res, Context context) {

    if (theHunt == null) {

        hrm = new HuntResourceManager();
        hrm.unzipFile(res);/*from w  ww .  j  av  a  2  s  .c  om*/

        theHunt = new Hunt(hrm.huntJSON, res, context);
        String android_id = Secure.getString(context.getContentResolver(), Secure.ANDROID_ID);

        if (android_id == null) {
            // Fall back on devices where ANDROID_ID is not reliable.
            theHunt.shuffle(Integer.parseInt(Settings.Secure.ANDROID_ID, 0));
        } else {
            BigInteger bi = new BigInteger(android_id, 16);
            System.out.println(bi);

            theHunt.shuffle(bi.shortValue());
        }
    }

    return theHunt;
}

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

/**
 * Converts a list of BigIntegers to a list of shorts.
 * @param    List<BigInteger>    list of BigIntegers
 * @return   List<Short          >     list of shorts
 *///from  w  w  w. j a v a  2  s  .  c  o m
public static List<Short> toShortList(List<BigInteger> list) {

    List<Short> shortList = new ArrayList<Short>();

    for (BigInteger val : list) {
        if (!OverFlowUtil.shortOverflow(val)) {
            OverFlowUtil.overflowError(val);
        }
        shortList.add(val.shortValue());
    }

    return shortList;

}

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

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

    if (this.reset) {
        initFlags = initFlags.setBit(15);
        initFlags = initFlags.setBit(14);
        initFlags = initFlags.setBit(13);
        initFlags = initFlags.setBit(12);
    }/*from   w  ww  .  j av  a 2s  . c o m*/
    if (this.initRequest) {
        initFlags = initFlags.setBit(6);
    }
    if (this.timeRequest) {
        initFlags = initFlags.setBit(5);
    }

    buffer.putShort(initFlags.shortValue());
    buffer.putShort((short) 0x5AA5);
}

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

/**
 * Convert a {@link BigInteger} to another type
 * //from w  w  w .  j a  va 2 s.  co 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;
}