<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 閱讀(7722) 評論(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
    主站蜘蛛池模板: 青柠影视在线观看免费| yellow视频免费看| 亚洲av丰满熟妇在线播放| 免费一级全黄少妇性色生活片 | 亚洲精品无码你懂的网站| 国产精品自拍亚洲| 四虎在线播放免费永久视频| 国产亚洲欧美日韩亚洲中文色| 中文字幕视频在线免费观看| 国产亚洲一区二区三区在线不卡| 四虎精品成人免费视频| 精品国产亚洲一区二区在线观看 | 亚洲成a人片在线观看中文!!!| 久久国产色AV免费观看| 亚洲va久久久久| 亚洲?V无码乱码国产精品 | 国产v亚洲v天堂无码网站| 性无码免费一区二区三区在线| 久久精品a亚洲国产v高清不卡| 一级毛片成人免费看a| 久久久久亚洲AV综合波多野结衣 | 最近的免费中文字幕视频| 亚洲暴爽av人人爽日日碰| 亚洲国产天堂久久综合| 日本三级在线观看免费| 91亚洲自偷在线观看国产馆| 在线视频免费国产成人| 999zyz**站免费毛片| 97se亚洲综合在线| 暖暖在线日本免费中文| 中国一级毛片视频免费看| 国产一区二区三区在线免费| 一级中文字幕乱码免费| 亚洲高清在线播放| 日韩免费视频观看| 在线成人精品国产区免费| 中文字幕无码亚洲欧洲日韩| 亚洲欧洲久久av| 国产卡一卡二卡三免费入口| www永久免费视频| 亚洲精品123区在线观看|