Example usage for java.math BigInteger floatValue

List of usage examples for java.math BigInteger floatValue

Introduction

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

Prototype

public float floatValue() 

Source Link

Document

Converts this BigInteger to a float .

Usage

From source file:Main.java

public static void main(String[] args) {

    // assign values to bi1, bi2
    BigInteger bi1 = new BigInteger("123");
    BigInteger bi2 = new BigInteger("-123");

    // assign float values of bi1, bi2 to f1, f2
    Float f1 = bi1.floatValue();
    Float f2 = bi2.floatValue();//  ww  w.ja  va2 s .  c o  m

    // print f1, f2 values
    System.out.println(f1);
    System.out.println(f2);
}

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

/**
 * Converts a list of BigIntegers to a list of floats.
 * @param    List<BigInteger>    list of BigIntegers
 * @return                       list of floats
 *//*from w  w w. j ava 2 s  . com*/
public static List<Float> toFloatList(List<BigInteger> list) {

    List<Float> floatList = new ArrayList<Float>();

    for (BigInteger val : list) {
        if (!OverFlowUtil.floatOverflow(val)) {
            OverFlowUtil.overflowError(val);
        }
        floatList.add(val.floatValue());
    }

    return floatList;

}

From source file:com.nec.harvest.service.impl.PettyCashServiceImpl.java

/** {@inheritDoc} */
@Override//from   w  ww.j  ava  2s  . c o m
public boolean checkAvailable(String orgCode, Date getSudo) throws ServiceException {
    if (StringUtils.isEmpty(orgCode) || getSudo == null) {
        throw new IllegalArgumentException(
                "To check month's data available, The input parameter organization code or business day must not be empty.");
    }

    final Session session = HibernateSessionManager.getSession();
    Transaction tx = null;

    boolean isAvailable = false;
    try {
        tx = session.beginTransaction();
        StringBuilder sql = new StringBuilder();
        sql.append(" SELECT count(recID) ");
        sql.append(" FROM AT009 ");
        sql.append(" WHERE strCode=:strCode AND getSudo=:getSudo AND delKbn=2");

        // 
        String strBusinessDay = DateFormatUtil.format(getSudo, DateFormat.DATE_WITHOUT_DAY);
        Query query = pettyCashRepository.getSQLQuery(session, sql.toString()).setString("strCode", orgCode)
                .setString("getSudo", strBusinessDay);

        BigInteger count = (BigInteger) query.uniqueResult();
        isAvailable = (count.floatValue() > 0);
        tx.commit();
    } catch (SQLGrammarException | GenericJDBCException ex) {
        if (tx != null) {
            tx.rollback();
        }
        throw new ServiceException("Hibernate runtime exception when check data available", ex);
    } finally {
        HibernateSessionManager.closeSession(session);
    }
    return isAvailable;
}

From source file:org.owasp.webscarab.plugin.sessionid.swing.SessionIDPanel.java

private void updateStats() {
    if (_key == null) {
        maxTextField.setText("");
        minTextField.setText("");
        rangeTextField.setText("");
        return;//from   w w w  .ja va 2  s.co  m
    }
    BigInteger min = _model.getMinimumValue(_key);
    BigInteger max = _model.getMaximumValue(_key);
    if (min != null) {
        minTextField.setText(min.toString());
    } else {
        minTextField.setText("");
    }
    if (max != null) {
        maxTextField.setText(max.toString());
    } else {
        maxTextField.setText("");
    }
    if (min != null && max != null) {
        BigInteger range = max.subtract(min);
        rangeTextField.setText(Float.toString(range.floatValue()));
    } else {
        rangeTextField.setText("");
    }
}

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

/**
 * Convert a {@link BigInteger} to another type
 * /*from  w ww .  ja  v a2 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;
}

From source file:org.plasma.sdo.helper.DataConverter.java

public Object fromInteger(Type targetType, BigInteger value) {
    DataType targetDataType = DataType.valueOf(targetType.getName());
    switch (targetDataType) {
    case Integer:
        return value;
    case Double:
        return new Double(value.doubleValue());
    case Float:
        return new Float(value.floatValue());
    case Int:/* w  w w  .j ava  2  s  .  c o m*/
        return new Integer(value.intValue());
    case Long:
        return new Long(value.longValue());
    case Decimal:
        return new BigDecimal(value.doubleValue());
    case Bytes:
        return value.toByteArray();
    case String:
        //as per spec: ('+'|'-')? [0-9]+
        return value.toString();
    default:
        throw new InvalidDataConversionException(targetDataType, DataType.Integer, value);
    }
}