<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    limq

    rainman
    隨筆 - 19, 文章 - 2, 評論 - 115, 引用 - 1
    數據加載中……

    四舍五入保留小數后兩位

     

     1 /**
     2  * Contains static utility methods.
     3  */
     4 public class BOUtils {
     5 
     6  public static Double getRoundedDouble( double unroundedValue ){
     7     // Get the integer portion of the value
     8     double intPortion = Math.floor( unroundedValue );
     9 
    10     // Get the unrounded decimal portion
    11     double unroundedDecimalPortion = ( unroundedValue - intPortion );
    12 
    13     /* ALERT - This next code interferes with I18N. We eventually need   */
    14     /*         to change this not assume only round to 2 decimal places. */
    15 
    16     /* Multiply the decimal places by 100, which shitfs the decimal point
    17     /* two places to the left. Then round it so that we get a round to
    18     /* two decimal places. For example, if we started with 17.655 and stripped
    19     /* off the int portion, which left .655. After we shift, we are left with
    20     /* 65.5. Then a round will gives us 66. We can then put it all back
    21     /* together */
    22     double roundedDecimalPortion = Math.round( unroundedDecimalPortion * 100 );
    23 
    24     // Shift the decimal point back two places to the right
    25     roundedDecimalPortion = roundedDecimalPortion / 100;
    26 
    27     // Add the int portion and decimal portions back together
    28     double total = intPortion + roundedDecimalPortion;
    29 
    30     return new Double( total );
    31   }
    32 }

    posted on 2005-09-21 23:59 limq 閱讀(7721) 評論(2)  編輯  收藏 所屬分類: 編程技巧

    評論

    # re: 四舍五入保留小數后兩位  回復  更多評論   

    new DecimalFormat("0.00").format(*******);
    這樣也可以,你那種太麻煩。
    2005-11-19 14:26 | 網絡幽靈

    # re: 四舍五入保留小數后兩位  回復  更多評論   

    是呀,在創建的時候,用數字的字符串形式創建,就可以了

    new BigDecimal("99.115").setScale(2, BigDecimal.ROUND_HARF_UP);
    2006-11-01 16:48 | Toez
    主站蜘蛛池模板: 一级毛片一级毛片免费毛片| 99亚偷拍自图区亚洲| 最近免费字幕中文大全| 久久人午夜亚洲精品无码区| a级毛片高清免费视频| 亚洲午夜久久久影院| 中文在线观看免费网站| 亚洲va无码手机在线电影| 亚洲欧美日韩综合俺去了| 午夜毛片不卡免费观看视频| 亚洲熟女一区二区三区| 成人性做爰aaa片免费看| 精品国产一区二区三区免费看| 亚洲AV永久无码精品水牛影视| 久久青草免费91线频观看不卡| 亚洲午夜视频在线观看| 国产福利在线观看免费第一福利| 亚洲乱码在线观看| 亚洲第一黄色网址| 亚洲精品无码专区在线播放| 国产青草视频免费观看97| 2022免费国产精品福利在线| 日韩电影免费在线| 亚洲人成7777| 亚洲成a人片在线播放| 最近免费mv在线观看动漫| 亚洲日韩乱码久久久久久| 四虎影视精品永久免费网站| 精品亚洲成在人线AV无码| 国产又粗又猛又爽又黄的免费视频| 两个人看的www高清免费观看| 亚洲福利秒拍一区二区| 午夜不卡久久精品无码免费| 亚洲人成网站在线观看青青| 99久久免费观看| 婷婷亚洲综合一区二区| 久久精品国产亚洲AV麻豆网站 | 国产成人亚洲精品蜜芽影院| 毛片免费全部免费观看| 久久精品国产99国产精品亚洲| 亚洲精品偷拍视频免费观看|