<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
    主站蜘蛛池模板: 亚洲麻豆精品果冻传媒| 国产亚洲老熟女视频| 亚洲精品美女久久久久9999| 最近2019中文免费字幕在线观看 | 曰皮全部过程视频免费国产30分钟 | 色www永久免费网站| 在线观看亚洲av每日更新| 中文字幕免费在线视频| 国产亚洲人成无码网在线观看| 中文字幕无码免费久久9一区9| 亚洲乱亚洲乱妇无码麻豆| 中文字幕无码日韩专区免费| 亚洲AV成人片色在线观看高潮 | 成人免费午夜在线观看| 亚洲视频在线观看2018| 精品国产麻豆免费网站| 人人爽人人爽人人片A免费| 久久精品国产亚洲Aⅴ香蕉 | 免费理论片51人人看电影| 小说专区亚洲春色校园| 亚洲中文字幕无码专区| 久久永久免费人妻精品| 亚洲日韩乱码中文无码蜜桃臀| 免费看美女让人桶尿口| 黄人成a动漫片免费网站| 亚洲精品成人片在线观看精品字幕| 中文字幕无码一区二区免费| 亚洲国产成+人+综合| 午夜国产大片免费观看| a级成人毛片免费视频高清| 亚洲女人初试黑人巨高清| 免费在线观看理论片| 久99久精品免费视频热77| 在线亚洲午夜片AV大片| 亚洲精品成人网久久久久久| 久久精品一区二区免费看| 亚洲综合精品第一页| 久久久青草青青亚洲国产免观| 欧美三级在线电影免费| 国产福利在线观看永久免费| 亚洲伊人久久大香线蕉影院|