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

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

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

    limq

    rainman
    隨筆 - 19, 文章 - 2, 評(píng)論 - 115, 引用 - 1
    數(shù)據(jù)加載中……

    四舍五入保留小數(shù)后兩位

     

     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 閱讀(7742) 評(píng)論(2)  編輯  收藏 所屬分類: 編程技巧

    評(píng)論

    # re: 四舍五入保留小數(shù)后兩位  回復(fù)  更多評(píng)論   

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

    # re: 四舍五入保留小數(shù)后兩位  回復(fù)  更多評(píng)論   

    是呀,在創(chuàng)建的時(shí)候,用數(shù)字的字符串形式創(chuàng)建,就可以了

    new BigDecimal("99.115").setScale(2, BigDecimal.ROUND_HARF_UP);
    2006-11-01 16:48 | Toez
    主站蜘蛛池模板: 免费福利在线观看| 国产免费直播在线观看视频| 日本一道在线日本一道高清不卡免费| 亚洲Av永久无码精品一区二区| 91免费国产自产地址入| 日韩亚洲国产综合久久久| 成av免费大片黄在线观看| 精品亚洲aⅴ在线观看| 国产高清免费在线| 日本卡1卡2卡三卡免费| 亚洲午夜福利717| 一区二区三区视频免费| 激情内射亚洲一区二区三区| 午夜免费福利在线观看| 最新亚洲春色Av无码专区| 99xxoo视频在线永久免费观看| 亚洲欧美成人一区二区三区| 亚洲日本va在线视频观看| 免费在线观看的网站| 九九99热免费最新版| 亚洲综合久久精品无码色欲| 亚洲午夜久久久久妓女影院| 成年性生交大片免费看| 国产午夜无码精品免费看动漫| 成人亚洲国产va天堂| 久久国产亚洲精品麻豆| 国产成人无码免费视频97| 99久久国产免费中文无字幕| 日韩一级片免费观看| 亚洲一区二区三区不卡在线播放| 亚洲偷自拍拍综合网| 成人网站免费大全日韩国产| 亚洲午夜无码毛片av久久京东热 | 一区二区三区免费视频观看| 亚洲午夜在线一区| 亚洲成a人片77777kkkk| yy6080久久亚洲精品| 天天摸夜夜摸成人免费视频| 最近免费中文字幕大全高清大全1 最近免费中文字幕mv在线电影 | 成年在线观看网站免费| 久久精品成人免费观看|