我试过以下,
double doubleVal = 1.745;
double doubleVal1 = 0.745;
BigDecimal bdTest = new BigDecimal( doubleVal);
BigDecimal bdTest1 = new BigDecimal( doubleVal1 );
bdTest = bdTest.setScale(2, BigDecimal.ROUND_HALF_UP);
bdTest1 = bdTest1.setScale(2, BigDecimal.ROUND_HALF_UP);
System.out.println("bdTest:"+bdTest); //1.75
System.out.println("bdTest1:"+bdTest1);//0.74 problemmmm ????????????
Run Code Online (Sandbox Code Playgroud)
但得到了奇怪的结果.为什么?
我的应用服务器ibm websphere.我在应用程序服务器日志中收到以下错误.我在哪里可以进行websphere设置?
[19.09.2012 14:56:54:940 EEST] 0000000a SystemErr R SLF4J:类路径包含多个SLF4J绑定.
[19.09.2012 14:56:54:940 EEST] 0000000a SystemErr R SLF4J:在[wsjar:file:/ C:/Lib/slf4j-log4j12-1.6.1.jar!/ org/slf4j/impl/StaticLoggerBinder中找到绑定.class]
[19.09.2012 14:56:54:941 EEST] 0000000a SystemErr R SLF4J:在[bundleresource://217.fwk37356669:1/org/slf4j/impl/StaticLoggerBinder.class]中找到绑定
[19.09.2012 14 :56:54:941 EEST] 0000000a SystemErr R SLF4J:请参阅http://www.slf4j.org/codes.html#multiple_bindings以获得解释.
我在下一行收到错误.我正在做添加到jsonarray的过程.请帮我.
jsonArr=new JSONArray();
if(req.getSession().getAttribute("userses")!=null){
String name=(req.getParameter("name")==null?"":to_EnglishName(req.getParameter("name").toUpperCase()));
if(!name.equals("")){
for(Book c:GlobalObjects.bookList){
if(c.getBookName().startsWith(name)){
jsonObjec=new JSONObject();
jsonObjec.put("label",c.getBookName());
jsonObjec.put("value", c.getId());
jsonArr.add(jsonObjec);//java.util.ConcurrentModificationException
}
}
}
}
jsonArr.write(res.getWriter());
Run Code Online (Sandbox Code Playgroud)