<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
    主站蜘蛛池模板: 亚洲国产精品线观看不卡 | 91短视频免费在线观看| 美女被爆羞羞网站免费| 亚洲欧洲校园自拍都市| 中文字幕亚洲一区| 国产成人精品男人免费| 中文字幕乱码免费视频| a级毛片高清免费视频| 精品一区二区三区无码免费直播 | 一区二区三区AV高清免费波多| 亚洲人成在线精品| 久久亚洲精品成人综合| 亚洲精品无码成人片在线观看| 最近高清国语中文在线观看免费| 91成人在线免费视频| 抽搐一进一出gif免费视频| 亚洲A∨精品一区二区三区下载 | 国产乱码免费卡1卡二卡3卡| 四虎国产成人永久精品免费 | 国产亚洲精品福利在线无卡一| 国产a级特黄的片子视频免费| 成人影片麻豆国产影片免费观看| 美丽的姑娘免费观看在线播放| 国产成人免费视频| 三年片在线观看免费西瓜视频| 国产精品福利在线观看免费不卡| 无忧传媒视频免费观看入口| 成年大片免费视频播放一级| 春暖花开亚洲性无区一区二区 | 国产香蕉免费精品视频| 99爱免费观看视频在线| 在线美女免费观看网站h| 久久久久久久久久国产精品免费 | 日韩毛片免费无码无毒视频观看| 91香蕉成人免费网站| 国产精品爱啪在线线免费观看| 最近中文字幕2019高清免费| 2019中文字幕在线电影免费| 四虎在线最新永久免费| 91情侣在线精品国产免费| 毛片免费全部播放一级|