你的问题是没有将数字格式化.
你可以使用
  DecimalFormat df = new DecimalFormat("0.00000000");
  df.format(double);
来解决

解决方案 »

  1.   

    DecimalFormat df = new DecimalFormat("##,###,###,###,###,##0.0000000000000");
    double argdouble;
    String str = df.format(argdouble);
      

  2.   

    用BigDecimal,数据库里的数字形域都推荐用BigDecimal,不会丢失精度
      

  3.   

    我建议用BigDecimal,可以任意长的小数。
      

  4.   

    我和tryst (刘术) 的问题基本上一致,但用了 honkyjiang(老蒋) 的方法的时候出现如下错误,是缺少哪些东西?500 Servlet Exception
    Note: sun.tools.javac.Main has been deprecated.
    /test.jsp:5: Class _jsp.DecimalFormat not found.
    DecimalFormat df = new DecimalFormat("##,###,###,###,###,##0.0000000000000");
    ^
    /test.jsp:5: Class _jsp.DecimalFormat not found.
    DecimalFormat df = new DecimalFormat("##,###,###,###,###,##0.0000000000000");
                           ^
    /test.jsp:9: Variable df may not have been initialized.
    String str = df.format(argdouble);
                 ^
    3 errors, 1 warning
      

  5.   

    回复人:tryst(刘术) ( ) 信誉:95  2003-10-20 11:27:00  得分:0

    我是用的他但是我想保留两位小数大家知道怎么办吗
    @see BigDecimal#setScale(int,int)比如:
    BigDecimal newDecimal = aDecimal.setScale(2, BigDecimal.ROUND_HALF_UP);
    这样就可以保留两位小数。
      

  6.   

    可以先转换成String,然后进行处理比较方便一些
      

  7.   

    java.math包中有两个类,BigInteger和BigDecimal,可用于具有任意长度的数字,BigInteger实现了任意长度的整数运算BigDecimal实现了任意精度的浮点数运算。
    用valueOf方法可以将一个普通数字转换成一个大数字(BigInteger a=BigInteger.valueOf(100); )。
    但是不能用+ - * / 运算符。必须用类中的方法(BigInteger c=a.add(b);)。
    ////////////BigInteger
    //BigInteger add(BigInteger other)
    //BigInteger subtract(BigInteger other)
    //BigInteger multiply(BigInteger other)
    //BigInteger divide(BigInteger other)
    //BigInteger mod(BigInteger other)
    //BigInteger compateTo(BigInteger other)
    ////////////////BigDecimal
    //BigDecimal add(BigDecimal other)
    //BigDecimal subtract(BigDecimal other)
    //BigDecimal multiply(BigDecimal other)
    //BigDecimal divide(BigDecimal other)
    ///////////////////////////////////////////
    import java.math.*;
    import javax.swing.*;
    public class BigIntegerTest
    {
      public static void main(String[] args)
      {
        String input=JOptionPane.showInputDialog("How many numbers do you need to draw?");
        int k=Integer.parseInt(input);
        input=JOptionPane.showInputDialog("How many numbers do you need to draw?");
        int n=Integer.parseInt(input);
        BigInteger lotteryOdds=BigInteger.valueOf(1);
        for(int i=1;i<=k;i++)
          lotteryOdds=lotteryOdds.multiply(BigInteger.valueOf(n-i+1)).divide(BigInteger.valueOf(i));
        System.out.println("Your odds are 1 in "+lotteryOdds+" . Good luck!");
        System.exit(0);
      }
    }
      

  8.   

    贴上来串位置了。
    java.math包中有两个类,BigInteger和BigDecimal,可用于具有任意长度的数字,
    BigInteger实现了任意长度的整数运算;
    BigDecimal实现了任意精度的浮点数运算。
    用valueOf方法可以将一个普通数字转换成一个大数字
    (BigInteger a=BigInteger.valueOf(100); )。
    但是不能用+ - * / 运算符。必须用类中的方法(BigInteger c=a.add(b);)。
    ////////////BigInteger
    //BigInteger add(BigInteger other)
    //BigInteger subtract(BigInteger other)
    //BigInteger multiply(BigInteger other)
    //BigInteger divide(BigInteger other)
    //BigInteger mod(BigInteger other)
    //BigInteger compateTo(BigInteger other)
    ////////////////BigDecimal
    //BigDecimal add(BigDecimal other)
    //BigDecimal subtract(BigDecimal other)
    //BigDecimal multiply(BigDecimal other)
    //BigDecimal divide(BigDecimal other)///////////////////////////////////////////示例
    import java.math.*;
    import javax.swing.*;
    public class BigIntegerTest
    {
      public static void main(String[] args)
      {
        String input=JOptionPane.showInputDialog("How many numbers do you need to 
    draw?");
        int k=Integer.parseInt(input);
        input=JOptionPane.showInputDialog("How many numbers do you need to draw?");
        int n=Integer.parseInt(input);
        BigInteger lotteryOdds=BigInteger.valueOf(1);
        for(int i=1;i<=k;i++)
           lotteryOdds=lotteryOdds
              .multiply(BigInteger.valueOf(n-i+1))
              .divide(BigInteger.valueOf(i));
        System.out.println("Your odds are 1 in "+lotteryOdds+" . Good luck!");
        System.exit(0);
      }
    }