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

    評論

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

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

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

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

    new BigDecimal("99.115").setScale(2, BigDecimal.ROUND_HARF_UP);
    2006-11-01 16:48 | Toez
    主站蜘蛛池模板: 免费乱码中文字幕网站| 成人黄18免费视频| 亚洲毛片αv无线播放一区| 无码AV动漫精品一区二区免费| 国产成人免费a在线资源| 青娱乐在线免费观看视频| 国产成人免费福利网站| 狼人大香伊蕉国产WWW亚洲| 免费a级毛片无码av| 九九九国产精品成人免费视频| 亚洲国产一区二区三区| a毛片免费在线观看| 亚洲制服中文字幕第一区| 9277手机在线视频观看免费| 亚洲一级毛片中文字幕| 在线精品免费视频无码的| 国产一区二区三区亚洲综合 | 亚洲色大18成人网站WWW在线播放| 在线观看免费高清视频| 亚洲a无码综合a国产av中文| 亚洲av无码专区在线观看素人| 亚洲天堂免费在线视频| 亚洲一区中文字幕久久| 精品少妇人妻AV免费久久洗澡| 日韩精品无码免费视频| 精品亚洲成a人片在线观看少妇| 亚洲人成电影网站免费| 在线观看亚洲精品专区| 国产亚洲精品国产| 青娱乐免费视频在线观看| 美女被免费网站在线视频免费| 亚洲一区二区三区无码中文字幕| 91在线手机精品免费观看| 亚洲AV无码一区二区乱子仑| 亚洲最大激情中文字幕| 欧美在线看片A免费观看| 国产精品1024在线永久免费 | 亚洲精品视频免费看| 亚洲av永久中文无码精品| 亚洲情XO亚洲色XO无码| 99久久免费国产精品特黄|