<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
    主站蜘蛛池模板: 成年女人午夜毛片免费视频| 久99久精品免费视频热77| 青苹果乐园免费高清在线| 亚洲日韩乱码中文无码蜜桃| 99在线免费观看视频| 亚洲人成电影亚洲人成9999网| 插鸡网站在线播放免费观看| 亚洲成AV人片在线观看| 成人人观看的免费毛片| 亚洲激情视频图片| 国内精品免费视频自在线| 亚洲欧美日韩中文字幕在线一区| 免费高清av一区二区三区| 亚洲AV无码一区二区三区鸳鸯影院| 国产精品色午夜视频免费看| 香蕉国产在线观看免费| 亚洲乱亚洲乱妇无码麻豆| 久操视频在线免费观看| 亚洲国产日产无码精品| 国产自产拍精品视频免费看| 窝窝影视午夜看片免费| 亚洲AV永久青草无码精品| 亚洲免费黄色网址| 国产综合成人亚洲区| 在线亚洲97se亚洲综合在线| 7m凹凸精品分类大全免费| 亚洲日本VA午夜在线影院| 亚洲高清无码综合性爱视频| 国产自国产自愉自愉免费24区 | 18成禁人视频免费网站| 亚洲中文字幕久久久一区| 亚洲精品视频在线看| 99国产精品免费视频观看| 亚洲人成自拍网站在线观看| 国产av无码专区亚洲国产精品| 51在线视频免费观看视频| 国产精品亚洲专区无码唯爱网 | 三年片免费高清版 | 成年女人毛片免费视频| 国产精品成人啪精品视频免费| 亚洲成a人不卡在线观看|