boutils.java
来自「《基于Eclipse的开源框架技术与实战》[第5章]随书源码」· Java 代码 · 共 41 行
JAVA
41 行
package com.free.struts.storefront.businessobjects;/** * <p>Title: Eclipse Plugin Development</p> * <p>Description: Free download</p> * <p>Copyright: Copyright (c) 2006</p> * <p>Company: Free</p> * @author gan.shu.man * @version 1.0 */public class BOUtils { public static Double getRoundedDouble(double unroundedValue) { // Get the integer portion of the value double intPortion = Math.floor(unroundedValue); // Get the unrounded decimal portion double unroundedDecimalPortion = (unroundedValue - intPortion); /* ALERT - This next code interferes with I18N. We eventually need */ /* to change this not assume only round to 2 decimal places. */ /* Multiply the decimal places by 100, which shitfs the decimal point /* two places to the left. Then round it so that we get a round to /* two decimal places. For example, if we started with 17.655 and stripped /* off the int portion, which left .655. After we shift, we are left with /* 65.5. Then a round will gives us 66. We can then put it all back /* together */ double roundedDecimalPortion = Math.round(unroundedDecimalPortion * 100); // Shift the decimal point back two places to the right roundedDecimalPortion = roundedDecimalPortion / 100; // Add the int portion and decimal portions back together double total = intPortion + roundedDecimalPortion; return new Double(total); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?