List of usage examples for java.math BigDecimal ROUND_HALF_EVEN
int ROUND_HALF_EVEN
To view the source code for java.math BigDecimal ROUND_HALF_EVEN.
Click Source Link
From source file:org.egov.egf.web.actions.payment.ChequeAssignmentAction.java
private void createRtgsAssignment(final Map<String, List<ChequeAssignment>> resultMap) throws Exception { instVoucherList = new ArrayList<>(); instVoucherDisplayList = new ArrayList<>(); for (final Entry<String, List<ChequeAssignment>> row : resultMap.entrySet()) if (row.getKey() != null && getRtgsSeceltedAccMap().get(row.getKey()) != null && getRtgsSeceltedAccMap().get(row.getKey())) { if (isRtgsNoGenerationAuto()) { final String[] dateArray = new String[] { getRtgsdateMap().get(String.valueOf(Long.valueOf(row.getKey()))) }; Date rtgsdate = null; final Date autoNoCutOffDate = FinancialConstants.RTGS_FINYEAR_WISE_ROLLING_SEQ_CUTOFF_DATE; String rtgsNo;/*from w w w . j a v a 2 s . c o m*/ if (dateArray[0] != null) { final String date = dateArray[0]; rtgsdate = formatter.parse(date); } final String finYearRange = financialYearDAO.getFinancialYearByDate(rtgsdate).getFinYearRange(); RtgsNumberGenerator rtgsNumberGenerator = beanResolver .getAutoNumberServiceFor(RtgsNumberGenerator.class); if (rtgsdate != null && rtgsdate.after(autoNoCutOffDate)) { rtgsNo = rtgsNumberGenerator .getNextNumber("RTGS_RefNumber_" + finYearRange.replace('-', '_')); rtgsNo = new StringBuilder().append(rtgsNo).append("/").append(finYearRange).toString(); } else rtgsNo = rtgsNumberGenerator.getNextNumber("RTGS_RefNumber"); final String[] refNoArray = new String[] { rtgsNo }; parameters.put("rtgsRefNo", refNoArray); } else { final String[] refNoArray = new String[] { getRtgsRefNoMap().get(row.getKey()) }; parameters.put("rtgsRefNo", refNoArray); } final String[] dateArray = new String[] { getRtgsdateMap().get(row.getKey()) }; parameters.put("rtgsDate", dateArray); chequeAssignmentList = resultMap.get(row.getKey()); bankaccount = Integer.parseInt(row.getKey()); paymentService.createInstrument(chequeAssignmentList, paymentMode, bankaccount, parameters, voucherHeader.getVouchermis().getDepartmentid()); instVoucherList.addAll(paymentService.getInstVoucherList()); List<InstrumentVoucher> tempInstVoucherList = new ArrayList<>(); for (InstrumentVoucher iv : instVoucherList) { Paymentheader payment = paymentService .getPaymentHeaderByVoucherHeaderId(iv.getVoucherHeaderId().getId()); iv.setPaymentAmount(payment.getPaymentAmount().setScale(2, BigDecimal.ROUND_HALF_EVEN)); tempInstVoucherList.add(iv); } instVoucherList = new ArrayList<>(); instVoucherList = tempInstVoucherList; } }
From source file:com.ardhi.businessgame.services.BusinessGameService.java
public String loadInstallmentOwnedByEquipment(HttpServletRequest req) { String val = "0", hiElement = "", equipmentType; double hiVal = 0, tmpd1, tmpd2; int eff;/*from w w w . j a va 2 s. com*/ SqlRowSet srs1 = db.getJdbc() .queryForRowSet("select equipment from list_equipment,desc_equipment where list_equipment.id='" + req.getParameter("id") + "' and list_equipment.[desc]=desc_equipment.id"), srs2, srs3; HashMap<String, Double> elementsRatio = new HashMap<String, Double>(), elements = new HashMap<String, Double>(), elementsCalc = new HashMap<String, Double>(); ArrayList<Installment> installments = new ArrayList<Installment>(); boolean pass = false; srs1.next(); equipmentType = srs1.getString("equipment"); srs1 = db.getJdbc().queryForRowSet( "select installment.id,[zone],type,draw,active from info_sector_equipment,installment,info_sector where equipment_type='" + equipmentType + "' and [user]='" + req.getParameter("user") + "' and [zone]=(select [zone] from businessgame.dbo.[user] where name='" + req.getParameter("user") + "') and installment.type=sector and type=name"); while (srs1.next()) { hiElement = ""; hiVal = 0; elementsRatio.clear(); elements.clear(); elementsCalc.clear(); pass = true; srs2 = db.getJdbc() .queryForRowSet("select equipment_type,items from info_sector_equipment where sector='" + srs1.getString("type") + "'"); while (srs2.next()) { elementsRatio.put(srs2.getString("equipment_type"), srs2.getDouble("items")); if (hiVal < srs2.getDouble("items")) { hiElement = srs2.getString("equipment_type"); hiVal = srs2.getDouble("items"); } srs3 = db.getJdbc().queryForRowSet( "select count(installment_equipment.id) from installment_equipment,list_equipment,desc_equipment where installment='" + srs1.getString("id") + "' and desc_equipment.equipment='" + srs2.getString("equipment_type") + "' and installment_equipment.id=list_equipment.id and list_equipment.[desc]=desc_equipment.id"); srs3.next(); elements.put(srs2.getString("equipment_type"), srs3.getDouble(1)); } srs2 = db.getJdbc().queryForRowSet("select employee_type,items from info_sector_employee where sector='" + srs1.getString("type") + "'"); while (srs2.next()) { elementsRatio.put(srs2.getString("employee_type"), srs2.getDouble("items")); if (hiVal < srs2.getDouble("items")) { hiElement = srs2.getString("employee_type"); hiVal = srs2.getDouble("items"); } srs3 = db.getJdbc().queryForRowSet( "select count(installment_employee.id) from installment_employee,list_employee,desc_employee where installment='" + srs1.getString("id") + "' and desc_employee.employee='" + srs2.getString("employee_type") + "' and installment_employee.id=list_employee.id and list_employee.[desc]=desc_employee.id"); srs3.next(); elements.put(srs2.getString("employee_type"), srs3.getDouble(1)); } //calculating: while (true) { for (String element : elementsRatio.keySet()) { if (element.equals(hiElement)) { elementsCalc.put(element, elements.get(element)); } else { elementsCalc.put(element, (elementsRatio.get(element) * elements.get(hiElement)) / elementsRatio.get(hiElement)); } } for (String element : elements.keySet()) { if (elements.get(element) < elementsCalc.get(element)) { pass = false; hiElement = element; hiVal = elements.get(element); break; } else { pass = true; } } if (pass) { eff = elements.get(hiElement).intValue() / elementsRatio.get(hiElement).intValue(); if (elements.get(hiElement) % elementsRatio.get(hiElement) > 0) { hiVal = (elementsRatio.get(hiElement) * (eff + 1)); if (hiVal > 0) tmpd1 = new BigDecimal(Double.valueOf( elementsCalc.get(hiElement) / (elementsRatio.get(hiElement) * (eff + 1)))) .setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue(); else tmpd1 = 0; tmpd2 = eff + 1; } else { hiVal = (elementsRatio.get(hiElement) * eff); if (hiVal > 0) tmpd1 = new BigDecimal(Double .valueOf(elementsCalc.get(hiElement) / (elementsRatio.get(hiElement) * eff))) .setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue(); else tmpd1 = 0; tmpd2 = eff; } installments.add( new Installment(srs1.getString("id"), srs1.getString("type"), srs1.getString("zone"), tmpd1, tmpd2, srs1.getString("draw"), srs1.getBoolean("active"))); break; } } } val = gson.toJson(installments); hiElement = null; elementsRatio = null; elements = null; elementsCalc = null; installments = null; gc(); return val; }
From source file:org.libreplan.business.orders.entities.OrderElement.java
/** * Calculates the work hours with the margin {@link Order#getHoursMargin()} for this orderElement. * * @return calculated work hours/*from ww w .j a v a 2s. c om*/ */ private EffortDuration calculateWorkHoursWithMargin() { BigDecimal margin = this.getOrder().getHoursMargin() != null ? new BigDecimal(this.getOrder().getHoursMargin()).setScale(2) : BigDecimal.ZERO; BigDecimal hundred = new BigDecimal(100); BigDecimal estimatedHours = new BigDecimal(getWorkHours()).setScale(2); BigDecimal marginHours = estimatedHours.multiply(margin).divide(hundred, 2, BigDecimal.ROUND_HALF_EVEN); BigDecimal result = estimatedHours.add(marginHours); return EffortDuration.fromHoursAsBigDecimal(result); }
From source file:org.kuali.kpme.tklm.leave.accrual.service.AccrualServiceImpl.java
private boolean minimumPercentageReachedForPayPeriod(BigDecimal min, String earnInterval, int workDays, DateTime intervalDate, String payCalName, Map<String, List<CalendarEntry>> aMap) { if (min == null || min.compareTo(BigDecimal.ZERO) == 0) { return true; }//from ww w. j av a 2s . c om int daysInInterval = this.getWorkDaysInInterval(intervalDate, earnInterval, payCalName, aMap); if (daysInInterval == 0) { return true; } BigDecimal actualPercentage = new BigDecimal(workDays).divide(new BigDecimal(daysInInterval), 2, BigDecimal.ROUND_HALF_EVEN); if (actualPercentage.compareTo(min) >= 0) { return true; } return false; }
From source file:org.libreplan.business.orders.entities.OrderElement.java
/** * Calculates the budget with the margin {@link Order#getBudgetMargin()} for this orderElement. * * @return calculated budget/*from www .j av a 2 s .com*/ */ private BigDecimal calculateBudgetWithMargin() { BigDecimal margin = this.getOrder().getBudgetMargin() != null ? new BigDecimal(this.getOrder().getBudgetMargin()) : BigDecimal.ZERO; BigDecimal hundred = new BigDecimal(100); BigDecimal budget = getBudget(); BigDecimal marginBudget = budget.multiply(margin).divide(hundred, 2, BigDecimal.ROUND_HALF_EVEN); return budget.add(marginBudget); }
From source file:org.egov.egf.web.actions.payment.PaymentAction.java
public String getComments() { if (LOGGER.isDebugEnabled()) LOGGER.debug("Inside getComments..."); return getText("payment.comments", new String[] { paymentheader.getPaymentAmount().setScale(2, BigDecimal.ROUND_HALF_EVEN).toPlainString() }); }
From source file:org.egov.ptis.service.es.PropertyTaxElasticSearchIndexService.java
/** * Provides citywise DCB details/*from www .j av a 2s. c o m*/ * @param collectionDetailsRequest * @return list */ public List<DCBDetails> getDCBDetails(final CollectionDetailsRequest collectionDetailsRequest) { final List<DCBDetails> dcbDetailsList = new ArrayList<>(); DCBDetails dCBDetails; String name; final Map<String, Map<String, BigDecimal>> demandDivisionMap = new HashMap<>(); final Map<String, BigDecimal> assessmentsCountMap = collectionIndexElasticSearchService .getCollectionAndDemandCountResults(collectionDetailsRequest, null, null, PROPERTY_TAX_INDEX_NAME, "consumerCode", CITY_NAME); final StringTerms individualDmdDetails = collectionIndexElasticSearchService .getIndividualDemands(collectionDetailsRequest, PROPERTY_TAX_INDEX_NAME, CITY_NAME, true); prepareDCBDetailsMap(individualDmdDetails, demandDivisionMap); for (final Map.Entry<String, Map<String, BigDecimal>> entry : demandDivisionMap.entrySet()) { dCBDetails = new DCBDetails(); name = entry.getKey(); dCBDetails.setBoundaryName(name); if (!assessmentsCountMap.isEmpty() && assessmentsCountMap.get(name) != null) dCBDetails.setTotalAssessments( assessmentsCountMap.get(name) == null ? BigDecimal.ZERO : assessmentsCountMap.get(name)); dCBDetails.setArrearDemand(demandDivisionMap.get(name).get(ARREAR_DMD) == null ? BigDecimal.ZERO : demandDivisionMap.get(name).get(ARREAR_DMD)); dCBDetails.setArrearPenalty(demandDivisionMap.get(name).get(ARREAR_INT_DMD) == null ? BigDecimal.ZERO : demandDivisionMap.get(name).get(ARREAR_INT_DMD)); dCBDetails.setCurrentDemand(demandDivisionMap.get(name).get(CURRENT_DMD) == null ? BigDecimal.ZERO : demandDivisionMap.get(name).get(CURRENT_DMD)); dCBDetails.setCurrentPenalty(demandDivisionMap.get(name).get(CURRENT_INT_DMD) == null ? BigDecimal.ZERO : demandDivisionMap.get(name).get(CURRENT_INT_DMD)); dCBDetails.setTotalDemand(demandDivisionMap.get(name).get(TOTAL_DMD_STR) == null ? BigDecimal.ZERO : demandDivisionMap.get(name).get(TOTAL_DMD_STR)); dCBDetails.setAdjustment(BigDecimal.ZERO); dCBDetails.setArrearColl(demandDivisionMap.get(name).get(ARREAR_COLL_STR) == null ? BigDecimal.ZERO : demandDivisionMap.get(name).get(ARREAR_COLL_STR)); dCBDetails.setCurrentColl(demandDivisionMap.get(name).get(CURRENT_COLL_STR) == null ? BigDecimal.ZERO : demandDivisionMap.get(name).get(CURRENT_COLL_STR)); dCBDetails .setArrearPenaltyColl(demandDivisionMap.get(name).get(ARREAR_INT_COLL) == null ? BigDecimal.ZERO : demandDivisionMap.get(name).get(ARREAR_INT_COLL)); dCBDetails.setCurrentPenaltyColl( demandDivisionMap.get(name).get(CURRENT_INT_COLL) == null ? BigDecimal.ZERO : demandDivisionMap.get(name).get(CURRENT_INT_COLL)); dCBDetails.setAdvanceColl(demandDivisionMap.get(name).get(ADVANCE_COLL_STR) == null ? BigDecimal.ZERO : demandDivisionMap.get(name).get(ADVANCE_COLL_STR)); dCBDetails.setRebate(demandDivisionMap.get(name).get(REBATE_STR) == null ? BigDecimal.ZERO : demandDivisionMap.get(name).get(REBATE_STR)); dCBDetails.setTotalColl(demandDivisionMap.get(name).get(TOTAL_COLL_STR) == null ? BigDecimal.ZERO : demandDivisionMap.get(name).get(TOTAL_COLL_STR)); if (dCBDetails.getTotalDemand().compareTo(BigDecimal.ZERO) > 0) dCBDetails.setPercentage(dCBDetails.getTotalColl().multiply(BIGDECIMAL_100) .divide(dCBDetails.getTotalDemand(), BigDecimal.ROUND_HALF_EVEN)); dcbDetailsList.add(dCBDetails); } return dcbDetailsList; }
From source file:com.lp.server.fertigung.ejbfac.FertigungFacBean.java
public void aendereLosgroesse(Integer losIId, Integer neueLosgroesse, boolean bUeberzaehligesMaterialZurueckgeben, TheClientDto theClientDto) { LosDto losDto = losFindByPrimaryKey(losIId); if (losDto.getStatusCNr().equals(FertigungFac.STATUS_AUSGEGEBEN) || losDto.getStatusCNr().equals(FertigungFac.STATUS_IN_PRODUKTION) || losDto.getStatusCNr().equals(FertigungFac.STATUS_GESTOPPT) || losDto.getStatusCNr().equals(FertigungFac.STATUS_TEILERLEDIGT)) { if (!losDto.getNLosgroesse().equals(new BigDecimal(neueLosgroesse))) { BigDecimal bdErledigte = getErledigteMenge(losDto.getIId(), theClientDto); if (bdErledigte.doubleValue() > neueLosgroesse.doubleValue()) { throw new EJBExceptionLP( EJBExceptionLP.FEHLER_FERTIGUNG_AENDERUNG_LOGROESSE_ZUVIELEABLIEFERUNGEN, new Exception("bdErledigte.doubleValue()>neueLosgroesse.doubleValue()")); }//from ww w.jav a 2 s . com Los los = em.find(Los.class, losDto.getIId()); los.setNLosgroesse(new BigDecimal(neueLosgroesse)); em.merge(los); em.flush(); // Material LossollmaterialDto[] dtos = lossollmaterialFindByLosIId(losIId); for (int i = 0; i < dtos.length; i++) { LossollmaterialDto dto = dtos[i]; // Sollmengen aendern BigDecimal sollsatzgroesse = dto.getNMenge().divide(losDto.getNLosgroesse(), 10, BigDecimal.ROUND_HALF_EVEN); dto.setNMenge( Helper.rundeKaufmaennisch(sollsatzgroesse.multiply(new BigDecimal(neueLosgroesse)), 3)); updateLossollmaterial(dto, theClientDto); // Wenn kleiner je nach parameter // bUeberzaehligesMaterialZurueckgeben material // zurueckbuchen if (neueLosgroesse.doubleValue() < losDto.getNLosgroesse().doubleValue() && bUeberzaehligesMaterialZurueckgeben == true) { BigDecimal bdAusgegeben = getAusgegebeneMenge(dto.getIId(), null, theClientDto); BigDecimal diff = bdAusgegeben.subtract(dto.getNMenge()); if (diff.doubleValue() > 0) { LosistmaterialDto[] dtosLosist = losistmaterialFindByLossollmaterialIId(dto.getIId()); for (int j = 0; j < dtosLosist.length; j++) { if (diff.doubleValue() > 0) { BigDecimal istmenge = dtosLosist[j].getNMenge(); BigDecimal bdMengeNeu = null; if (diff.doubleValue() > istmenge.doubleValue()) { bdMengeNeu = new BigDecimal(0); diff = diff.subtract(istmenge); } else { bdMengeNeu = istmenge.subtract(diff); diff = new BigDecimal(0); } updateLosistmaterialMenge(dtosLosist[j].getIId(), bdMengeNeu, theClientDto); } } } } // Fehlmengen aktualisieren try { getFehlmengeFac().aktualisiereFehlmenge(LocaleFac.BELEGART_LOS, dto.getIId(), false, theClientDto); } catch (RemoteException e) { throwEJBExceptionLPRespectOld(e); } } // Arbeitsplan LossollarbeitsplanDto[] arbeitsplan = lossollarbeitsplanFindByLosIId(losIId); for (int i = 0; i < arbeitsplan.length; i++) { LossollarbeitsplanDto dto = arbeitsplan[i]; // Gesamtzeit wird austomatisch aktualisiert updateLossollarbeitsplan(dto, theClientDto); } } } else { if (losDto.getStatusCNr().equals(FertigungFac.STATUS_STORNIERT)) { throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FERTIGUNG_DAS_LOS_IST_STORNIERT, new Exception("los " + losDto.getCNr() + " ist storniert")); } else if (losDto.getStatusCNr().equals(FertigungFac.STATUS_ERLEDIGT)) { throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FERTIGUNG_DAS_LOS_IST_BEREITS_ERLEDIGT, new Exception("los " + losDto.getCNr() + " ist bereits erledigt")); } else if (losDto.getStatusCNr().equals(FertigungFac.STATUS_ANGELEGT)) { throw new EJBExceptionLP(EJBExceptionLP.FEHLER_FERTIGUNG_DAS_LOS_IST_NOCH_NICHT_AUSGEGEBEN, new Exception("los " + losDto.getCNr() + " ist noch nicht ausgegeben")); } } }
From source file:org.pentaho.di.core.ConstTest.java
@Test public void testRound() { assertEquals(1.0, Const.round(1.0, 0, BigDecimal.ROUND_UP)); assertEquals(1.0, Const.round(1.0, 0, BigDecimal.ROUND_DOWN)); assertEquals(1.0, Const.round(1.0, 0, BigDecimal.ROUND_CEILING)); assertEquals(1.0, Const.round(1.0, 0, BigDecimal.ROUND_FLOOR)); assertEquals(1.0, Const.round(1.0, 0, BigDecimal.ROUND_HALF_UP)); assertEquals(1.0, Const.round(1.0, 0, BigDecimal.ROUND_HALF_DOWN)); assertEquals(1.0, Const.round(1.0, 0, BigDecimal.ROUND_HALF_EVEN)); assertEquals(1.0, Const.round(1.0, 0, Const.ROUND_HALF_CEILING)); assertEquals(2.0, Const.round(1.2, 0, BigDecimal.ROUND_UP)); assertEquals(1.0, Const.round(1.2, 0, BigDecimal.ROUND_DOWN)); assertEquals(2.0, Const.round(1.2, 0, BigDecimal.ROUND_CEILING)); assertEquals(1.0, Const.round(1.2, 0, BigDecimal.ROUND_FLOOR)); assertEquals(1.0, Const.round(1.2, 0, BigDecimal.ROUND_HALF_UP)); assertEquals(1.0, Const.round(1.2, 0, BigDecimal.ROUND_HALF_DOWN)); assertEquals(1.0, Const.round(1.2, 0, BigDecimal.ROUND_HALF_EVEN)); assertEquals(1.0, Const.round(1.2, 0, Const.ROUND_HALF_CEILING)); assertEquals(2.0, Const.round(1.5, 0, BigDecimal.ROUND_UP)); assertEquals(1.0, Const.round(1.5, 0, BigDecimal.ROUND_DOWN)); assertEquals(2.0, Const.round(1.5, 0, BigDecimal.ROUND_CEILING)); assertEquals(1.0, Const.round(1.5, 0, BigDecimal.ROUND_FLOOR)); assertEquals(2.0, Const.round(1.5, 0, BigDecimal.ROUND_HALF_UP)); assertEquals(1.0, Const.round(1.5, 0, BigDecimal.ROUND_HALF_DOWN)); assertEquals(2.0, Const.round(1.5, 0, BigDecimal.ROUND_HALF_EVEN)); assertEquals(2.0, Const.round(1.5, 0, Const.ROUND_HALF_CEILING)); assertEquals(2.0, Const.round(1.7, 0, BigDecimal.ROUND_UP)); assertEquals(1.0, Const.round(1.7, 0, BigDecimal.ROUND_DOWN)); assertEquals(2.0, Const.round(1.7, 0, BigDecimal.ROUND_CEILING)); assertEquals(1.0, Const.round(1.7, 0, BigDecimal.ROUND_FLOOR)); assertEquals(2.0, Const.round(1.7, 0, BigDecimal.ROUND_HALF_UP)); assertEquals(2.0, Const.round(1.7, 0, BigDecimal.ROUND_HALF_DOWN)); assertEquals(2.0, Const.round(1.7, 0, BigDecimal.ROUND_HALF_EVEN)); assertEquals(2.0, Const.round(1.7, 0, Const.ROUND_HALF_CEILING)); assertEquals(2.0, Const.round(2.0, 0, BigDecimal.ROUND_UP)); assertEquals(2.0, Const.round(2.0, 0, BigDecimal.ROUND_DOWN)); assertEquals(2.0, Const.round(2.0, 0, BigDecimal.ROUND_CEILING)); assertEquals(2.0, Const.round(2.0, 0, BigDecimal.ROUND_FLOOR)); assertEquals(2.0, Const.round(2.0, 0, BigDecimal.ROUND_HALF_UP)); assertEquals(2.0, Const.round(2.0, 0, BigDecimal.ROUND_HALF_DOWN)); assertEquals(2.0, Const.round(2.0, 0, BigDecimal.ROUND_HALF_EVEN)); assertEquals(2.0, Const.round(2.0, 0, Const.ROUND_HALF_CEILING)); assertEquals(3.0, Const.round(2.2, 0, BigDecimal.ROUND_UP)); assertEquals(2.0, Const.round(2.2, 0, BigDecimal.ROUND_DOWN)); assertEquals(3.0, Const.round(2.2, 0, BigDecimal.ROUND_CEILING)); assertEquals(2.0, Const.round(2.2, 0, BigDecimal.ROUND_FLOOR)); assertEquals(2.0, Const.round(2.2, 0, BigDecimal.ROUND_HALF_UP)); assertEquals(2.0, Const.round(2.2, 0, BigDecimal.ROUND_HALF_DOWN)); assertEquals(2.0, Const.round(2.2, 0, BigDecimal.ROUND_HALF_EVEN)); assertEquals(2.0, Const.round(2.2, 0, Const.ROUND_HALF_CEILING)); assertEquals(3.0, Const.round(2.5, 0, BigDecimal.ROUND_UP)); assertEquals(2.0, Const.round(2.5, 0, BigDecimal.ROUND_DOWN)); assertEquals(3.0, Const.round(2.5, 0, BigDecimal.ROUND_CEILING)); assertEquals(2.0, Const.round(2.5, 0, BigDecimal.ROUND_FLOOR)); assertEquals(3.0, Const.round(2.5, 0, BigDecimal.ROUND_HALF_UP)); assertEquals(2.0, Const.round(2.5, 0, BigDecimal.ROUND_HALF_DOWN)); assertEquals(2.0, Const.round(2.5, 0, BigDecimal.ROUND_HALF_EVEN)); assertEquals(3.0, Const.round(2.5, 0, Const.ROUND_HALF_CEILING)); assertEquals(3.0, Const.round(2.7, 0, BigDecimal.ROUND_UP)); assertEquals(2.0, Const.round(2.7, 0, BigDecimal.ROUND_DOWN)); assertEquals(3.0, Const.round(2.7, 0, BigDecimal.ROUND_CEILING)); assertEquals(2.0, Const.round(2.7, 0, BigDecimal.ROUND_FLOOR)); assertEquals(3.0, Const.round(2.7, 0, BigDecimal.ROUND_HALF_UP)); assertEquals(3.0, Const.round(2.7, 0, BigDecimal.ROUND_HALF_DOWN)); assertEquals(3.0, Const.round(2.7, 0, BigDecimal.ROUND_HALF_EVEN)); assertEquals(3.0, Const.round(2.7, 0, Const.ROUND_HALF_CEILING)); assertEquals(-1.0, Const.round(-1.0, 0, BigDecimal.ROUND_UP)); assertEquals(-1.0, Const.round(-1.0, 0, BigDecimal.ROUND_DOWN)); assertEquals(-1.0, Const.round(-1.0, 0, BigDecimal.ROUND_CEILING)); assertEquals(-1.0, Const.round(-1.0, 0, BigDecimal.ROUND_FLOOR)); assertEquals(-1.0, Const.round(-1.0, 0, BigDecimal.ROUND_HALF_UP)); assertEquals(-1.0, Const.round(-1.0, 0, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-1.0, Const.round(-1.0, 0, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-1.0, Const.round(-1.0, 0, Const.ROUND_HALF_CEILING)); assertEquals(-2.0, Const.round(-1.2, 0, BigDecimal.ROUND_UP)); assertEquals(-1.0, Const.round(-1.2, 0, BigDecimal.ROUND_DOWN)); assertEquals(-1.0, Const.round(-1.2, 0, BigDecimal.ROUND_CEILING)); assertEquals(-2.0, Const.round(-1.2, 0, BigDecimal.ROUND_FLOOR)); assertEquals(-1.0, Const.round(-1.2, 0, BigDecimal.ROUND_HALF_UP)); assertEquals(-1.0, Const.round(-1.2, 0, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-1.0, Const.round(-1.2, 0, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-1.0, Const.round(-1.2, 0, Const.ROUND_HALF_CEILING)); assertEquals(-2.0, Const.round(-1.5, 0, BigDecimal.ROUND_UP)); assertEquals(-1.0, Const.round(-1.5, 0, BigDecimal.ROUND_DOWN)); assertEquals(-1.0, Const.round(-1.5, 0, BigDecimal.ROUND_CEILING)); assertEquals(-2.0, Const.round(-1.5, 0, BigDecimal.ROUND_FLOOR)); assertEquals(-2.0, Const.round(-1.5, 0, BigDecimal.ROUND_HALF_UP)); assertEquals(-1.0, Const.round(-1.5, 0, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-2.0, Const.round(-1.5, 0, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-1.0, Const.round(-1.5, 0, Const.ROUND_HALF_CEILING)); assertEquals(-2.0, Const.round(-1.7, 0, BigDecimal.ROUND_UP)); assertEquals(-1.0, Const.round(-1.7, 0, BigDecimal.ROUND_DOWN)); assertEquals(-1.0, Const.round(-1.7, 0, BigDecimal.ROUND_CEILING)); assertEquals(-2.0, Const.round(-1.7, 0, BigDecimal.ROUND_FLOOR)); assertEquals(-2.0, Const.round(-1.7, 0, BigDecimal.ROUND_HALF_UP)); assertEquals(-2.0, Const.round(-1.7, 0, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-2.0, Const.round(-1.7, 0, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-2.0, Const.round(-1.7, 0, Const.ROUND_HALF_CEILING)); assertEquals(-2.0, Const.round(-2.0, 0, BigDecimal.ROUND_UP)); assertEquals(-2.0, Const.round(-2.0, 0, BigDecimal.ROUND_DOWN)); assertEquals(-2.0, Const.round(-2.0, 0, BigDecimal.ROUND_CEILING)); assertEquals(-2.0, Const.round(-2.0, 0, BigDecimal.ROUND_FLOOR)); assertEquals(-2.0, Const.round(-2.0, 0, BigDecimal.ROUND_HALF_UP)); assertEquals(-2.0, Const.round(-2.0, 0, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-2.0, Const.round(-2.0, 0, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-2.0, Const.round(-2.0, 0, Const.ROUND_HALF_CEILING)); assertEquals(-3.0, Const.round(-2.2, 0, BigDecimal.ROUND_UP)); assertEquals(-2.0, Const.round(-2.2, 0, BigDecimal.ROUND_DOWN)); assertEquals(-2.0, Const.round(-2.2, 0, BigDecimal.ROUND_CEILING)); assertEquals(-3.0, Const.round(-2.2, 0, BigDecimal.ROUND_FLOOR)); assertEquals(-2.0, Const.round(-2.2, 0, BigDecimal.ROUND_HALF_UP)); assertEquals(-2.0, Const.round(-2.2, 0, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-2.0, Const.round(-2.2, 0, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-2.0, Const.round(-2.2, 0, Const.ROUND_HALF_CEILING)); assertEquals(-3.0, Const.round(-2.5, 0, BigDecimal.ROUND_UP)); assertEquals(-2.0, Const.round(-2.5, 0, BigDecimal.ROUND_DOWN)); assertEquals(-2.0, Const.round(-2.5, 0, BigDecimal.ROUND_CEILING)); assertEquals(-3.0, Const.round(-2.5, 0, BigDecimal.ROUND_FLOOR)); assertEquals(-3.0, Const.round(-2.5, 0, BigDecimal.ROUND_HALF_UP)); assertEquals(-2.0, Const.round(-2.5, 0, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-2.0, Const.round(-2.5, 0, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-2.0, Const.round(-2.5, 0, Const.ROUND_HALF_CEILING)); assertEquals(-3.0, Const.round(-2.7, 0, BigDecimal.ROUND_UP)); assertEquals(-2.0, Const.round(-2.7, 0, BigDecimal.ROUND_DOWN)); assertEquals(-2.0, Const.round(-2.7, 0, BigDecimal.ROUND_CEILING)); assertEquals(-3.0, Const.round(-2.7, 0, BigDecimal.ROUND_FLOOR)); assertEquals(-3.0, Const.round(-2.7, 0, BigDecimal.ROUND_HALF_UP)); assertEquals(-3.0, Const.round(-2.7, 0, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-3.0, Const.round(-2.7, 0, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-3.0, Const.round(-2.7, 0, Const.ROUND_HALF_CEILING)); assertEquals(0.010, Const.round(0.010, 2, BigDecimal.ROUND_UP)); assertEquals(0.010, Const.round(0.010, 2, BigDecimal.ROUND_DOWN)); assertEquals(0.010, Const.round(0.010, 2, BigDecimal.ROUND_CEILING)); assertEquals(0.010, Const.round(0.010, 2, BigDecimal.ROUND_FLOOR)); assertEquals(0.010, Const.round(0.010, 2, BigDecimal.ROUND_HALF_UP)); assertEquals(0.010, Const.round(0.010, 2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(0.010, Const.round(0.010, 2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(0.010, Const.round(0.010, 2, Const.ROUND_HALF_CEILING)); assertEquals(0.020, Const.round(0.012, 2, BigDecimal.ROUND_UP)); assertEquals(0.010, Const.round(0.012, 2, BigDecimal.ROUND_DOWN)); assertEquals(0.020, Const.round(0.012, 2, BigDecimal.ROUND_CEILING)); assertEquals(0.010, Const.round(0.012, 2, BigDecimal.ROUND_FLOOR)); assertEquals(0.010, Const.round(0.012, 2, BigDecimal.ROUND_HALF_UP)); assertEquals(0.010, Const.round(0.012, 2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(0.010, Const.round(0.012, 2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(0.010, Const.round(0.012, 2, Const.ROUND_HALF_CEILING)); assertEquals(0.020, Const.round(0.015, 2, BigDecimal.ROUND_UP)); assertEquals(0.010, Const.round(0.015, 2, BigDecimal.ROUND_DOWN)); assertEquals(0.020, Const.round(0.015, 2, BigDecimal.ROUND_CEILING)); assertEquals(0.010, Const.round(0.015, 2, BigDecimal.ROUND_FLOOR)); assertEquals(0.020, Const.round(0.015, 2, BigDecimal.ROUND_HALF_UP)); assertEquals(0.010, Const.round(0.015, 2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(0.020, Const.round(0.015, 2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(0.020, Const.round(0.015, 2, Const.ROUND_HALF_CEILING)); assertEquals(0.020, Const.round(0.017, 2, BigDecimal.ROUND_UP)); assertEquals(0.010, Const.round(0.017, 2, BigDecimal.ROUND_DOWN)); assertEquals(0.020, Const.round(0.017, 2, BigDecimal.ROUND_CEILING)); assertEquals(0.010, Const.round(0.017, 2, BigDecimal.ROUND_FLOOR)); assertEquals(0.020, Const.round(0.017, 2, BigDecimal.ROUND_HALF_UP)); assertEquals(0.020, Const.round(0.017, 2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(0.020, Const.round(0.017, 2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(0.020, Const.round(0.017, 2, Const.ROUND_HALF_CEILING)); assertEquals(0.020, Const.round(0.020, 2, BigDecimal.ROUND_UP)); assertEquals(0.020, Const.round(0.020, 2, BigDecimal.ROUND_DOWN)); assertEquals(0.020, Const.round(0.020, 2, BigDecimal.ROUND_CEILING)); assertEquals(0.020, Const.round(0.020, 2, BigDecimal.ROUND_FLOOR)); assertEquals(0.020, Const.round(0.020, 2, BigDecimal.ROUND_HALF_UP)); assertEquals(0.020, Const.round(0.020, 2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(0.020, Const.round(0.020, 2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(0.020, Const.round(0.020, 2, Const.ROUND_HALF_CEILING)); assertEquals(0.030, Const.round(0.022, 2, BigDecimal.ROUND_UP)); assertEquals(0.020, Const.round(0.022, 2, BigDecimal.ROUND_DOWN)); assertEquals(0.030, Const.round(0.022, 2, BigDecimal.ROUND_CEILING)); assertEquals(0.020, Const.round(0.022, 2, BigDecimal.ROUND_FLOOR)); assertEquals(0.020, Const.round(0.022, 2, BigDecimal.ROUND_HALF_UP)); assertEquals(0.020, Const.round(0.022, 2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(0.020, Const.round(0.022, 2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(0.020, Const.round(0.022, 2, Const.ROUND_HALF_CEILING)); assertEquals(0.030, Const.round(0.025, 2, BigDecimal.ROUND_UP)); assertEquals(0.020, Const.round(0.025, 2, BigDecimal.ROUND_DOWN)); assertEquals(0.030, Const.round(0.025, 2, BigDecimal.ROUND_CEILING)); assertEquals(0.020, Const.round(0.025, 2, BigDecimal.ROUND_FLOOR)); assertEquals(0.030, Const.round(0.025, 2, BigDecimal.ROUND_HALF_UP)); assertEquals(0.020, Const.round(0.025, 2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(0.020, Const.round(0.025, 2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(0.030, Const.round(0.025, 2, Const.ROUND_HALF_CEILING)); assertEquals(0.030, Const.round(0.027, 2, BigDecimal.ROUND_UP)); assertEquals(0.020, Const.round(0.027, 2, BigDecimal.ROUND_DOWN)); assertEquals(0.030, Const.round(0.027, 2, BigDecimal.ROUND_CEILING)); assertEquals(0.020, Const.round(0.027, 2, BigDecimal.ROUND_FLOOR)); assertEquals(0.030, Const.round(0.027, 2, BigDecimal.ROUND_HALF_UP)); assertEquals(0.030, Const.round(0.027, 2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(0.030, Const.round(0.027, 2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(0.030, Const.round(0.027, 2, Const.ROUND_HALF_CEILING)); assertEquals(-0.010, Const.round(-0.010, 2, BigDecimal.ROUND_UP)); assertEquals(-0.010, Const.round(-0.010, 2, BigDecimal.ROUND_DOWN)); assertEquals(-0.010, Const.round(-0.010, 2, BigDecimal.ROUND_CEILING)); assertEquals(-0.010, Const.round(-0.010, 2, BigDecimal.ROUND_FLOOR)); assertEquals(-0.010, Const.round(-0.010, 2, BigDecimal.ROUND_HALF_UP)); assertEquals(-0.010, Const.round(-0.010, 2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-0.010, Const.round(-0.010, 2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-0.010, Const.round(-0.010, 2, Const.ROUND_HALF_CEILING)); assertEquals(-0.020, Const.round(-0.012, 2, BigDecimal.ROUND_UP)); assertEquals(-0.010, Const.round(-0.012, 2, BigDecimal.ROUND_DOWN)); assertEquals(-0.010, Const.round(-0.012, 2, BigDecimal.ROUND_CEILING)); assertEquals(-0.020, Const.round(-0.012, 2, BigDecimal.ROUND_FLOOR)); assertEquals(-0.010, Const.round(-0.012, 2, BigDecimal.ROUND_HALF_UP)); assertEquals(-0.010, Const.round(-0.012, 2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-0.010, Const.round(-0.012, 2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-0.010, Const.round(-0.012, 2, Const.ROUND_HALF_CEILING)); assertEquals(-0.020, Const.round(-0.015, 2, BigDecimal.ROUND_UP)); assertEquals(-0.010, Const.round(-0.015, 2, BigDecimal.ROUND_DOWN)); assertEquals(-0.010, Const.round(-0.015, 2, BigDecimal.ROUND_CEILING)); assertEquals(-0.020, Const.round(-0.015, 2, BigDecimal.ROUND_FLOOR)); assertEquals(-0.020, Const.round(-0.015, 2, BigDecimal.ROUND_HALF_UP)); assertEquals(-0.010, Const.round(-0.015, 2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-0.020, Const.round(-0.015, 2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-0.010, Const.round(-0.015, 2, Const.ROUND_HALF_CEILING)); assertEquals(-0.020, Const.round(-0.017, 2, BigDecimal.ROUND_UP)); assertEquals(-0.010, Const.round(-0.017, 2, BigDecimal.ROUND_DOWN)); assertEquals(-0.010, Const.round(-0.017, 2, BigDecimal.ROUND_CEILING)); assertEquals(-0.020, Const.round(-0.017, 2, BigDecimal.ROUND_FLOOR)); assertEquals(-0.020, Const.round(-0.017, 2, BigDecimal.ROUND_HALF_UP)); assertEquals(-0.020, Const.round(-0.017, 2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-0.020, Const.round(-0.017, 2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-0.020, Const.round(-0.017, 2, Const.ROUND_HALF_CEILING)); assertEquals(-0.020, Const.round(-0.020, 2, BigDecimal.ROUND_UP)); assertEquals(-0.020, Const.round(-0.020, 2, BigDecimal.ROUND_DOWN)); assertEquals(-0.020, Const.round(-0.020, 2, BigDecimal.ROUND_CEILING)); assertEquals(-0.020, Const.round(-0.020, 2, BigDecimal.ROUND_FLOOR)); assertEquals(-0.020, Const.round(-0.020, 2, BigDecimal.ROUND_HALF_UP)); assertEquals(-0.020, Const.round(-0.020, 2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-0.020, Const.round(-0.020, 2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-0.020, Const.round(-0.020, 2, Const.ROUND_HALF_CEILING)); assertEquals(-0.030, Const.round(-0.022, 2, BigDecimal.ROUND_UP)); assertEquals(-0.020, Const.round(-0.022, 2, BigDecimal.ROUND_DOWN)); assertEquals(-0.020, Const.round(-0.022, 2, BigDecimal.ROUND_CEILING)); assertEquals(-0.030, Const.round(-0.022, 2, BigDecimal.ROUND_FLOOR)); assertEquals(-0.020, Const.round(-0.022, 2, BigDecimal.ROUND_HALF_UP)); assertEquals(-0.020, Const.round(-0.022, 2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-0.020, Const.round(-0.022, 2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-0.020, Const.round(-0.022, 2, Const.ROUND_HALF_CEILING)); assertEquals(-0.030, Const.round(-0.025, 2, BigDecimal.ROUND_UP)); assertEquals(-0.020, Const.round(-0.025, 2, BigDecimal.ROUND_DOWN)); assertEquals(-0.020, Const.round(-0.025, 2, BigDecimal.ROUND_CEILING)); assertEquals(-0.030, Const.round(-0.025, 2, BigDecimal.ROUND_FLOOR)); assertEquals(-0.030, Const.round(-0.025, 2, BigDecimal.ROUND_HALF_UP)); assertEquals(-0.020, Const.round(-0.025, 2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-0.020, Const.round(-0.025, 2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-0.020, Const.round(-0.025, 2, Const.ROUND_HALF_CEILING)); assertEquals(-0.030, Const.round(-0.027, 2, BigDecimal.ROUND_UP)); assertEquals(-0.020, Const.round(-0.027, 2, BigDecimal.ROUND_DOWN)); assertEquals(-0.020, Const.round(-0.027, 2, BigDecimal.ROUND_CEILING)); assertEquals(-0.030, Const.round(-0.027, 2, BigDecimal.ROUND_FLOOR)); assertEquals(-0.030, Const.round(-0.027, 2, BigDecimal.ROUND_HALF_UP)); assertEquals(-0.030, Const.round(-0.027, 2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-0.030, Const.round(-0.027, 2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-0.030, Const.round(-0.027, 2, Const.ROUND_HALF_CEILING)); assertEquals(100.0, Const.round(100.0, -2, BigDecimal.ROUND_UP)); assertEquals(100.0, Const.round(100.0, -2, BigDecimal.ROUND_DOWN)); assertEquals(100.0, Const.round(100.0, -2, BigDecimal.ROUND_CEILING)); assertEquals(100.0, Const.round(100.0, -2, BigDecimal.ROUND_FLOOR)); assertEquals(100.0, Const.round(100.0, -2, BigDecimal.ROUND_HALF_UP)); assertEquals(100.0, Const.round(100.0, -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(100.0, Const.round(100.0, -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(100.0, Const.round(100.0, -2, Const.ROUND_HALF_CEILING)); assertEquals(200.0, Const.round(120.0, -2, BigDecimal.ROUND_UP)); assertEquals(100.0, Const.round(120.0, -2, BigDecimal.ROUND_DOWN)); assertEquals(200.0, Const.round(120.0, -2, BigDecimal.ROUND_CEILING)); assertEquals(100.0, Const.round(120.0, -2, BigDecimal.ROUND_FLOOR)); assertEquals(100.0, Const.round(120.0, -2, BigDecimal.ROUND_HALF_UP)); assertEquals(100.0, Const.round(120.0, -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(100.0, Const.round(120.0, -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(100.0, Const.round(120.0, -2, Const.ROUND_HALF_CEILING)); assertEquals(200.0, Const.round(150.0, -2, BigDecimal.ROUND_UP)); assertEquals(100.0, Const.round(150.0, -2, BigDecimal.ROUND_DOWN)); assertEquals(200.0, Const.round(150.0, -2, BigDecimal.ROUND_CEILING)); assertEquals(100.0, Const.round(150.0, -2, BigDecimal.ROUND_FLOOR)); assertEquals(200.0, Const.round(150.0, -2, BigDecimal.ROUND_HALF_UP)); assertEquals(100.0, Const.round(150.0, -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(200.0, Const.round(150.0, -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(200.0, Const.round(150.0, -2, Const.ROUND_HALF_CEILING)); assertEquals(200.0, Const.round(170.0, -2, BigDecimal.ROUND_UP)); assertEquals(100.0, Const.round(170.0, -2, BigDecimal.ROUND_DOWN)); assertEquals(200.0, Const.round(170.0, -2, BigDecimal.ROUND_CEILING)); assertEquals(100.0, Const.round(170.0, -2, BigDecimal.ROUND_FLOOR)); assertEquals(200.0, Const.round(170.0, -2, BigDecimal.ROUND_HALF_UP)); assertEquals(200.0, Const.round(170.0, -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(200.0, Const.round(170.0, -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(200.0, Const.round(170.0, -2, Const.ROUND_HALF_CEILING)); assertEquals(200.0, Const.round(200.0, -2, BigDecimal.ROUND_UP)); assertEquals(200.0, Const.round(200.0, -2, BigDecimal.ROUND_DOWN)); assertEquals(200.0, Const.round(200.0, -2, BigDecimal.ROUND_CEILING)); assertEquals(200.0, Const.round(200.0, -2, BigDecimal.ROUND_FLOOR)); assertEquals(200.0, Const.round(200.0, -2, BigDecimal.ROUND_HALF_UP)); assertEquals(200.0, Const.round(200.0, -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(200.0, Const.round(200.0, -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(200.0, Const.round(200.0, -2, Const.ROUND_HALF_CEILING)); assertEquals(300.0, Const.round(220.0, -2, BigDecimal.ROUND_UP)); assertEquals(200.0, Const.round(220.0, -2, BigDecimal.ROUND_DOWN)); assertEquals(300.0, Const.round(220.0, -2, BigDecimal.ROUND_CEILING)); assertEquals(200.0, Const.round(220.0, -2, BigDecimal.ROUND_FLOOR)); assertEquals(200.0, Const.round(220.0, -2, BigDecimal.ROUND_HALF_UP)); assertEquals(200.0, Const.round(220.0, -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(200.0, Const.round(220.0, -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(200.0, Const.round(220.0, -2, Const.ROUND_HALF_CEILING)); assertEquals(300.0, Const.round(250.0, -2, BigDecimal.ROUND_UP)); assertEquals(200.0, Const.round(250.0, -2, BigDecimal.ROUND_DOWN)); assertEquals(300.0, Const.round(250.0, -2, BigDecimal.ROUND_CEILING)); assertEquals(200.0, Const.round(250.0, -2, BigDecimal.ROUND_FLOOR)); assertEquals(300.0, Const.round(250.0, -2, BigDecimal.ROUND_HALF_UP)); assertEquals(200.0, Const.round(250.0, -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(200.0, Const.round(250.0, -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(300.0, Const.round(250.0, -2, Const.ROUND_HALF_CEILING)); assertEquals(300.0, Const.round(270.0, -2, BigDecimal.ROUND_UP)); assertEquals(200.0, Const.round(270.0, -2, BigDecimal.ROUND_DOWN)); assertEquals(300.0, Const.round(270.0, -2, BigDecimal.ROUND_CEILING)); assertEquals(200.0, Const.round(270.0, -2, BigDecimal.ROUND_FLOOR)); assertEquals(300.0, Const.round(270.0, -2, BigDecimal.ROUND_HALF_UP)); assertEquals(300.0, Const.round(270.0, -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(300.0, Const.round(270.0, -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(300.0, Const.round(270.0, -2, Const.ROUND_HALF_CEILING)); assertEquals(-100.0, Const.round(-100.0, -2, BigDecimal.ROUND_UP)); assertEquals(-100.0, Const.round(-100.0, -2, BigDecimal.ROUND_DOWN)); assertEquals(-100.0, Const.round(-100.0, -2, BigDecimal.ROUND_CEILING)); assertEquals(-100.0, Const.round(-100.0, -2, BigDecimal.ROUND_FLOOR)); assertEquals(-100.0, Const.round(-100.0, -2, BigDecimal.ROUND_HALF_UP)); assertEquals(-100.0, Const.round(-100.0, -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-100.0, Const.round(-100.0, -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-100.0, Const.round(-100.0, -2, Const.ROUND_HALF_CEILING)); assertEquals(-200.0, Const.round(-120.0, -2, BigDecimal.ROUND_UP)); assertEquals(-100.0, Const.round(-120.0, -2, BigDecimal.ROUND_DOWN)); assertEquals(-100.0, Const.round(-120.0, -2, BigDecimal.ROUND_CEILING)); assertEquals(-200.0, Const.round(-120.0, -2, BigDecimal.ROUND_FLOOR)); assertEquals(-100.0, Const.round(-120.0, -2, BigDecimal.ROUND_HALF_UP)); assertEquals(-100.0, Const.round(-120.0, -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-100.0, Const.round(-120.0, -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-100.0, Const.round(-120.0, -2, Const.ROUND_HALF_CEILING)); assertEquals(-200.0, Const.round(-150.0, -2, BigDecimal.ROUND_UP)); assertEquals(-100.0, Const.round(-150.0, -2, BigDecimal.ROUND_DOWN)); assertEquals(-100.0, Const.round(-150.0, -2, BigDecimal.ROUND_CEILING)); assertEquals(-200.0, Const.round(-150.0, -2, BigDecimal.ROUND_FLOOR)); assertEquals(-200.0, Const.round(-150.0, -2, BigDecimal.ROUND_HALF_UP)); assertEquals(-100.0, Const.round(-150.0, -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-200.0, Const.round(-150.0, -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-100.0, Const.round(-150.0, -2, Const.ROUND_HALF_CEILING)); assertEquals(-200.0, Const.round(-170.0, -2, BigDecimal.ROUND_UP)); assertEquals(-100.0, Const.round(-170.0, -2, BigDecimal.ROUND_DOWN)); assertEquals(-100.0, Const.round(-170.0, -2, BigDecimal.ROUND_CEILING)); assertEquals(-200.0, Const.round(-170.0, -2, BigDecimal.ROUND_FLOOR)); assertEquals(-200.0, Const.round(-170.0, -2, BigDecimal.ROUND_HALF_UP)); assertEquals(-200.0, Const.round(-170.0, -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-200.0, Const.round(-170.0, -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-200.0, Const.round(-170.0, -2, Const.ROUND_HALF_CEILING)); assertEquals(-200.0, Const.round(-200.0, -2, BigDecimal.ROUND_UP)); assertEquals(-200.0, Const.round(-200.0, -2, BigDecimal.ROUND_DOWN)); assertEquals(-200.0, Const.round(-200.0, -2, BigDecimal.ROUND_CEILING)); assertEquals(-200.0, Const.round(-200.0, -2, BigDecimal.ROUND_FLOOR)); assertEquals(-200.0, Const.round(-200.0, -2, BigDecimal.ROUND_HALF_UP)); assertEquals(-200.0, Const.round(-200.0, -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-200.0, Const.round(-200.0, -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-200.0, Const.round(-200.0, -2, Const.ROUND_HALF_CEILING)); assertEquals(-300.0, Const.round(-220.0, -2, BigDecimal.ROUND_UP)); assertEquals(-200.0, Const.round(-220.0, -2, BigDecimal.ROUND_DOWN)); assertEquals(-200.0, Const.round(-220.0, -2, BigDecimal.ROUND_CEILING)); assertEquals(-300.0, Const.round(-220.0, -2, BigDecimal.ROUND_FLOOR)); assertEquals(-200.0, Const.round(-220.0, -2, BigDecimal.ROUND_HALF_UP)); assertEquals(-200.0, Const.round(-220.0, -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-200.0, Const.round(-220.0, -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-200.0, Const.round(-220.0, -2, Const.ROUND_HALF_CEILING)); assertEquals(-300.0, Const.round(-250.0, -2, BigDecimal.ROUND_UP)); assertEquals(-200.0, Const.round(-250.0, -2, BigDecimal.ROUND_DOWN)); assertEquals(-200.0, Const.round(-250.0, -2, BigDecimal.ROUND_CEILING)); assertEquals(-300.0, Const.round(-250.0, -2, BigDecimal.ROUND_FLOOR)); assertEquals(-300.0, Const.round(-250.0, -2, BigDecimal.ROUND_HALF_UP)); assertEquals(-200.0, Const.round(-250.0, -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-200.0, Const.round(-250.0, -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-200.0, Const.round(-250.0, -2, Const.ROUND_HALF_CEILING)); assertEquals(-300.0, Const.round(-270.0, -2, BigDecimal.ROUND_UP)); assertEquals(-200.0, Const.round(-270.0, -2, BigDecimal.ROUND_DOWN)); assertEquals(-200.0, Const.round(-270.0, -2, BigDecimal.ROUND_CEILING)); assertEquals(-300.0, Const.round(-270.0, -2, BigDecimal.ROUND_FLOOR)); assertEquals(-300.0, Const.round(-270.0, -2, BigDecimal.ROUND_HALF_UP)); assertEquals(-300.0, Const.round(-270.0, -2, BigDecimal.ROUND_HALF_DOWN)); assertEquals(-300.0, Const.round(-270.0, -2, BigDecimal.ROUND_HALF_EVEN)); assertEquals(-300.0, Const.round(-270.0, -2, Const.ROUND_HALF_CEILING)); assertEquals(Double.NaN, Const.round(Double.NaN, 0, BigDecimal.ROUND_UP)); assertEquals(Double.NEGATIVE_INFINITY, Const.round(Double.NEGATIVE_INFINITY, 0, BigDecimal.ROUND_UP)); assertEquals(Double.POSITIVE_INFINITY, Const.round(Double.POSITIVE_INFINITY, 0, BigDecimal.ROUND_UP)); }
From source file:com.ardhi.businessgame.services.BusinessGameService.java
public String loadInstallmentOwnedByUserFromSelectedType(HttpServletRequest req) { System.out.println("Tes"); String val = "0", hiElement = ""; // val = gson.toJson(calculateInstallmentByUser(req.getParameter("user"))); double hiVal = 0, tmpd1, tmpd2; int eff;// w w w . j a v a2s . co m SqlRowSet srs1 = db.getJdbc() .queryForRowSet("select id,[zone],type,draw,active from installment,info_sector where [user]='" + req.getParameter("user") + "' and type='" + req.getParameter("type") + "' and [zone]=(select [zone] from businessgame.dbo.[user] where name='" + req.getParameter("user") + "') and name=type"), srs2, srs3; HashMap<String, Double> elementsRatio = new HashMap<String, Double>(), elements = new HashMap<String, Double>(), elementsCalc = new HashMap<String, Double>(); ArrayList<Installment> installments = new ArrayList<Installment>(); boolean pass = false; while (srs1.next()) { hiElement = ""; hiVal = 0; elementsRatio.clear(); elements.clear(); elementsCalc.clear(); pass = true; srs2 = db.getJdbc() .queryForRowSet("select equipment_type,items from info_sector_equipment where sector='" + srs1.getString("type") + "'"); while (srs2.next()) { elementsRatio.put(srs2.getString("equipment_type"), srs2.getDouble("items")); if (hiVal < srs2.getDouble("items")) { hiElement = srs2.getString("equipment_type"); hiVal = srs2.getDouble("items"); } srs3 = db.getJdbc().queryForRowSet( "select count(installment_equipment.id) from installment_equipment,list_equipment,desc_equipment where installment='" + srs1.getString("id") + "' and desc_equipment.equipment='" + srs2.getString("equipment_type") + "' and installment_equipment.id=list_equipment.id and list_equipment.[desc]=desc_equipment.id"); srs3.next(); elements.put(srs2.getString("equipment_type"), srs3.getDouble(1)); } srs2 = db.getJdbc().queryForRowSet("select employee_type,items from info_sector_employee where sector='" + srs1.getString("type") + "'"); while (srs2.next()) { elementsRatio.put(srs2.getString("employee_type"), srs2.getDouble("items")); if (hiVal < srs2.getDouble("items")) { hiElement = srs2.getString("employee_type"); hiVal = srs2.getDouble("items"); } srs3 = db.getJdbc().queryForRowSet( "select count(installment_employee.id) from installment_employee,list_employee,desc_employee where installment='" + srs1.getString("id") + "' and desc_employee.employee='" + srs2.getString("employee_type") + "' and installment_employee.id=list_employee.id and list_employee.[desc]=desc_employee.id"); srs3.next(); elements.put(srs2.getString("employee_type"), srs3.getDouble(1)); } //calculating: while (true) { for (String element : elementsRatio.keySet()) { if (element.equals(hiElement)) { elementsCalc.put(element, elements.get(element)); } else { elementsCalc.put(element, (elementsRatio.get(element) * elements.get(hiElement)) / elementsRatio.get(hiElement)); } } for (String element : elements.keySet()) { if (elements.get(element) < elementsCalc.get(element)) { pass = false; hiElement = element; hiVal = elements.get(element); break; } else { pass = true; } } if (pass) { eff = elements.get(hiElement).intValue() / elementsRatio.get(hiElement).intValue(); if (elements.get(hiElement) % elementsRatio.get(hiElement) > 0) { hiVal = (elementsRatio.get(hiElement) * (eff + 1)); if (hiVal > 0) tmpd1 = new BigDecimal(Double.valueOf( elementsCalc.get(hiElement) / (elementsRatio.get(hiElement) * (eff + 1)))) .setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue(); else tmpd1 = 0; tmpd2 = eff + 1; } else { hiVal = (elementsRatio.get(hiElement) * eff); if (hiVal > 0) tmpd1 = new BigDecimal(Double .valueOf(elementsCalc.get(hiElement) / (elementsRatio.get(hiElement) * eff))) .setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue(); else tmpd1 = 0; tmpd2 = eff; } installments.add( new Installment(srs1.getString("id"), srs1.getString("type"), srs1.getString("zone"), tmpd1, tmpd2, srs1.getString("draw"), srs1.getBoolean("active"))); break; } } } val = gson.toJson(installments); installments = null; hiElement = null; srs1 = null; srs2 = null; srs3 = null; elements = null; elementsCalc = null; elementsRatio = null; gc(); return val; }