Example usage for java.math BigDecimal doubleValue

List of usage examples for java.math BigDecimal doubleValue

Introduction

In this page you can find the example usage for java.math BigDecimal doubleValue.

Prototype

@Override
public double doubleValue() 

Source Link

Document

Converts this BigDecimal to a double .

Usage

From source file:com.qiangbang.controller.wap.BusinessController.java

/**
 * /*from  ww w  .  j  a va 2s.c  om*/
  * @Title: goShopSet 
  * @Description: TODO  
  * @return void  
  * @throws
 */
public void goShopSet() {
    Users users = (Users) getRequest().getSession().getAttribute("users");
    int uid = users.getInt("id");
    Business business = Business.me.findByUid(uid);
    Record record = Evaluate.me.findAvgService(uid);
    double avgService = 0;
    double avgSpeed = 0;
    double avgQuality = 0;

    HashMap<String, Object> res = new HashMap<String, Object>();
    res.put("allavg", 0);
    if (record != null) {
        BigDecimal serv = record.getBigDecimal("serv");
        avgService = serv == null ? 0 : serv.doubleValue();
        BigDecimal speed = record.getBigDecimal("speed");
        avgSpeed = speed == null ? 0 : speed.doubleValue();
        BigDecimal qua = record.getBigDecimal("qua");
        avgQuality = qua == null ? 0 : qua.doubleValue();

        double allavg = avgService + avgSpeed + avgQuality;
        if (allavg > 0) {
            res.put("allavg", allavg / 3);
        }
    }

    setAttr("res", res);
    setAttr("business", business);
    render("shop/set.jsp");
}

From source file:com.nkapps.billing.services.BankStatementPrintServiceImpl.java

public boolean createCell(HSSFRow row, int cellCurrent, HSSFCellStyle[] style, BigDecimal value) {
    HSSFCell cell;/*w w w .  j av a 2  s.  c om*/
    cell = row.createCell(cellCurrent);
    if (value == null) {
        cell.setCellValue("");
    } else {
        cell.setCellValue(value.doubleValue());
    }
    cell.setCellStyle(style[cellCurrent++]);
    return true;
}

From source file:org.jasig.portlet.maps.mvc.portlet.MapViewController.java

/**
 * Get the Lat or Long value, giving preference to
 * 1) Portlet preference value// w w w .j av a  2 s.  c o  m
 * 2) value specified in map file
 * 3) fail safe default
 * @param preferences
 * @param mapValue
 * @param preferenceName
 * @param defaultValue
 * @return
 */
private Double getLatOrLong(PortletPreferences preferences, BigDecimal mapValue, String preferenceName,
        String defaultValue) {
    String preferenceValue = preferences.getValue(preferenceName, null);
    if (preferenceValue != null) {
        return Double.parseDouble(preferenceValue);
    } else if (mapValue != null) {
        return mapValue.doubleValue();
    }
    return Double.parseDouble(defaultValue);
}

From source file:fixio.fixprotocol.fields.FieldFactoryTest.java

@Test
public void testValueOfFloat() throws Exception {
    BigDecimal value = BigDecimal.valueOf(new Random().nextInt()).movePointLeft(5);

    FloatField field = FieldFactory.valueOf(FieldType.SettlCurrFxRate.tag(),
            value.toPlainString().getBytes(US_ASCII));

    assertEquals("tagnum", FieldType.SettlCurrFxRate.tag(), field.getTagNum());
    assertEquals("value", value.doubleValue(), field.getValue().doubleValue(), 0.0);
    assertEquals("value", value.floatValue(), field.floatValue(), 0.0);

}

From source file:fsm.series.Series_CC.java

public strictfp double getF1Value(double y, int m, int n) {

    double um = getMu_m(m);
    double un = getMu_m(n);

    double alphaM = (sin(um) - sinh(um)) / (cos(um) - cosh(um));

    double alphaN = (sin(un) - sinh(un)) / (cos(un) - cosh(un));

    double km = um / a;
    double kn = un / a;

    BigDecimal Ym;//www  . j  a v a2  s.  c  om
    BigDecimal Yn;

    BigDecimal cosh = new BigDecimal(-alphaM * -cosh(km * y));
    BigDecimal sinh = new BigDecimal(-sinh(km * y));
    BigDecimal sin = new BigDecimal(sin(km * y));
    BigDecimal cos = new BigDecimal(-alphaM * cos(km * y));

    Ym = (cos.add(sin).add(sinh).add(cosh));

    BigDecimal coshN = new BigDecimal(-alphaN * -cosh(kn * y));
    BigDecimal sinhN = new BigDecimal(-sinh(kn * y));
    BigDecimal sinN = new BigDecimal(sin(kn * y));
    BigDecimal cosN = new BigDecimal(-alphaN * cos(kn * y));

    Yn = cosN.add(sinN).add(sinhN).add(coshN);

    BigDecimal ans = Ym.multiply(Yn);

    return ans.doubleValue();

}

From source file:com.qiangbang.controller.wap.BusinessController.java

/**
 * ??/*from w w w.j  a v a  2 s.c om*/
 */
public void shopDetail() {
    UserService userService = Duang.duang(UserService.class);
    int uid = getParaToInt();
    int count = userService.getBusCount(uid);//
    double busamount = userService.getBusSumPrice(uid);//
    Business business = Business.me.findByUid(uid);

    Record record = Evaluate.me.findAvgService(uid);
    double avgService = 0;
    double avgSpeed = 0;
    double avgQuality = 0;
    int sum = 0;
    int goodper = 0;
    HashMap<String, Object> res = new HashMap<String, Object>();
    if (record != null) {
        BigDecimal serv = record.getBigDecimal("serv");
        avgService = serv == null ? 0 : serv.doubleValue();
        BigDecimal speed = record.getBigDecimal("speed");
        avgSpeed = speed == null ? 0 : speed.doubleValue();
        BigDecimal qua = record.getBigDecimal("qua");
        avgQuality = qua == null ? 0 : qua.doubleValue();

        res.put("avgService", avgService);
        res.put("avgSpeed", avgSpeed);
        res.put("avgQuality", avgQuality);

        double allavg = avgService + avgSpeed + avgQuality;
        if (allavg > 0) {
            res.put("allavg", allavg / 3);
        } else {
            res.put("allavg", 0);
        }

        Long esum = record.getLong("esum");
        sum = esum == null ? 0 : esum.intValue();
        Long good = record.getLong("good");
        goodper = good == null ? 0 : good.intValue();
        if (sum == 0 || goodper == 0) {
            res.put("goodpercent", 0);
        } else {
            res.put("goodpercent", ((goodper / sum) * 100));
        }
    }
    setAttr("res", res);
    setAttr("count", count);
    setAttr("busamount", busamount);
    setAttr("business", business);
    setAttr("evalrec", record);
    setAttr("isself", 0);
    render("shop/index.jsp");
}

From source file:fsm.series.Series_CC.java

public strictfp double getF2Value(double y, int m, int n) {

    double Pi = Math.PI;

    double um = getMu_m(m);
    double un = getMu_m(n);

    double alphaM = (sin(um) - sinh(um)) / (cos(um) - cosh(um));

    double alphaN = (sin(un) - sinh(un)) / (cos(un) - cosh(un));

    double km = um / a;
    double kn = un / a;

    BigDecimal Ymd2;//from  www .  j  ava  2 s.c  o m
    BigDecimal Yn;

    BigDecimal cosh = new BigDecimal(alphaM * km * km * cosh(km * y));

    BigDecimal sinh = new BigDecimal(-km * km * sinh(km * y));
    BigDecimal sin = new BigDecimal(-km * km * sin(km * y));
    BigDecimal cos = new BigDecimal(alphaM * km * km * cos(km * y));

    Ymd2 = (cos.add(sin).add(sinh).add(cosh));

    BigDecimal coshN = new BigDecimal(-alphaN * -cosh(kn * y));
    BigDecimal sinhN = new BigDecimal(-sinh(kn * y));
    BigDecimal sinN = new BigDecimal(sin(kn * y));
    BigDecimal cosN = new BigDecimal(-alphaN * cos(kn * y));

    Yn = cosN.add(sinN).add(sinhN).add(coshN);

    BigDecimal ans = Ymd2.multiply(Yn);

    return ans.doubleValue();
}

From source file:fsm.series.Series_CC.java

public strictfp double getF4Value(double y, int m, int n) {

    double um = getMu_m(m);
    double un = getMu_m(n);

    double alphaM = (sin(um) - sinh(um)) / (cos(um) - cosh(um));

    double alphaN = (sin(un) - sinh(un)) / (cos(un) - cosh(un));

    double km = um / a;
    double kn = un / a;

    BigDecimal Ymd2;//from ww w. j  a v  a2  s  .  c  o  m
    BigDecimal Ynd2;

    BigDecimal cosh = new BigDecimal(alphaM * km * km * cosh(km * y));

    BigDecimal sinh = new BigDecimal(-km * km * sinh(km * y));
    BigDecimal sin = new BigDecimal(-km * km * sin(km * y));
    BigDecimal cos = new BigDecimal(alphaM * km * km * cos(km * y));

    Ymd2 = (cos.add(sin).add(sinh).add(cosh));

    BigDecimal coshN = new BigDecimal(alphaN * kn * kn * cosh(kn * y));

    BigDecimal sinhN = new BigDecimal(-kn * kn * sinh(kn * y));
    BigDecimal sinN = new BigDecimal(-kn * kn * sin(kn * y));
    BigDecimal cosN = new BigDecimal(alphaN * kn * kn * cos(kn * y));

    Ynd2 = cosN.add(sinN).add(sinhN).add(coshN);

    BigDecimal ans = Ymd2.multiply(Ynd2);

    return ans.doubleValue();
}

From source file:fsm.series.Series_CC.java

public strictfp double getF5Value(double y, int m, int n) {

    double um = getMu_m(m);
    double un = getMu_m(n);

    double alphaM = (sin(um) - sinh(um)) / (cos(um) - cosh(um));

    double alphaN = (sin(un) - sinh(un)) / (cos(un) - cosh(un));

    double km = um / a;
    double kn = un / a;

    BigDecimal Ymd1;//from   w  ww  . j a v a  2s.c  om
    BigDecimal Ynd1;

    BigDecimal cosh = new BigDecimal(-km * cosh(km * y));

    BigDecimal sinh = new BigDecimal(alphaM * km * sinh(km * y));
    BigDecimal sin = new BigDecimal(alphaM * km * sin(km * y));
    BigDecimal cos = new BigDecimal(km * cos(km * y));

    Ymd1 = (cos.add(sin).add(sinh).add(cosh));

    BigDecimal coshN = new BigDecimal(-kn * cosh(kn * y));

    BigDecimal sinhN = new BigDecimal(alphaN * kn * sinh(kn * y));
    BigDecimal sinN = new BigDecimal(alphaN * kn * sin(kn * y));
    BigDecimal cosN = new BigDecimal(kn * cos(kn * y));

    Ynd1 = cosN.add(sinN).add(sinhN).add(coshN);

    BigDecimal ans = Ymd1.multiply(Ynd1);

    return ans.doubleValue();
}

From source file:io.rapidpro.androidchannel.json.JSON.java

public void put(String key, BigDecimal decimal) {
    try {//from w  w w. ja v  a2 s. c  o m
        if (decimal == null) {
            m_o.put(key, null);
        } else {
            m_o.put(key, decimal.doubleValue());
        }
    } catch (Throwable t) {
        throw new JSONException(t);
    }
}