java格式化小數

          package com.gpe.ukweb.invoice;

          import java.math.BigDecimal;

          public class FormatNumber {
          ?public FormatNumber(){}
          ?public static double Double(String d,int i){
          ??BigDecimal b = new BigDecimal(d);
          ??BigDecimal one = new BigDecimal("1");
          ??return b.divide(one,i,BigDecimal.ROUND_HALF_UP).doubleValue();
          ?}
          ?public static double Double(double d){
          ??return Double(Double.toString(d),2);
          ?}
          ?
          ?public static String strDouble(String d,int i){
          ??BigDecimal b = new BigDecimal(d);
          ??BigDecimal one = new BigDecimal("1");
          ??return b.divide(one,i,BigDecimal.ROUND_HALF_UP).toString();??
          ?}
          ?public static String strDouble(double d){
          ??return strDouble(Double.toString(d),2);
          ?}
          ?public static void main(String[] args){
          ??String ss="523.9999";
          ??System.out.println(FormatNumber.strDouble(ss,6));
          ?}?

          }

          posted on 2006-10-18 10:19 leoli 閱讀(503) 評論(0)  編輯  收藏 所屬分類: java

          導航

          <2025年7月>
          293012345
          6789101112
          13141516171819
          20212223242526
          272829303112
          3456789

          統計

          常用鏈接

          留言簿(6)

          隨筆分類

          隨筆檔案(17)

          文章分類(86)

          收藏夾(3)

          flex blog

          good site

          java blog

          my friend

          tools

          抓蝦

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 通州市| 唐河县| 天镇县| 徐闻县| 阳谷县| 博湖县| 新田县| 锡林郭勒盟| 阿克| 平远县| 凯里市| 依安县| 衡山县| 西安市| 焉耆| 辉南县| 济阳县| 绵竹市| 广元市| 周宁县| 耒阳市| 白城市| 禄丰县| 永福县| 建阳市| 银川市| 宝兴县| 海安县| 青铜峡市| 马尔康县| 江陵县| 喀喇沁旗| 加查县| 阜南县| 昭通市| 仲巴县| 河津市| 都昌县| 清远市| 陆丰市| 巴东县|