/*
2008年9月22日16:34:17
请问Infinity到底是什么东西?
*/class E
{
public static void main(String[] args)
{
double data = 100.0 / 0.0;
System.out.printf("%f\n", data);
//System.out.println(Infinity); //编译时这行代码出错
}
}
/*
在JDK 1.6中的运行结果是:
--------------------------
Infinity
--------------------------
请问:在《java学习笔记》中讲到:“在java除法中,允许浮点数运算时除
数为零,所得结果是Infinity”, 我在帮助文档的的Double类中查不到Infinity这个字段
直接写
System.out.println(Infinity);
编译时也会出错,那请问Infinity到底是什么东西啊?

*/

解决方案 »

  1.   

    Infinity??
    JAVA里面没这个东东吧!
      

  2.   

    System.out.println(Double.POSITIVE_INFINITY);
      System.out.println(Float.POSITIVE_INFINITY);
      

  3.   

    Infinity means "Wu Xian".
      

  4.   


    // OR
    System.out.println(Float.intBitsToFloat(0x7f800000));
      

  5.   

    无穷大
    float把0.0当成一个无限小的数据
      

  6.   

    Read the last code and its result:
    http://blog.csdn.net/justinavril/archive/2008/09/06/2891266.aspx
      

  7.   

    也就是无穷大的意思,
    可以用System.out.println(Double.POSITIVE_INFINITY)输出。
      

  8.   

    问题是Infinity 与 Double.POSITIVE_INFINITY 到底是什么关系?
      

  9.   

    保持 double 类型的正无穷大的常量。它等于 Double.longBitsToDouble(0x7ff0000000000000L) 返回的值。
    即Infinity的意思。
      

  10.   

    问题是为什么不能直接输出Infinity?
    即System.out.println(Infinity); 是错误的
    class M
    {
            public static void main(String[] args)
    {
                    System.out.printf("%f\n", Double.POSITIVE_INFINITY );
                    System.out.printf("%f\n",  
                                   Double.longBitsToDouble(0x7ff0000000000000L));
                   //System.out.printf("%f\n",  Infinity); //本语句为何是错误的,怎样直接使用Infinity
            }

      

  11.   

    晕,直接写Infinity的话是什么意思啊?
    要么你把他定义成一变量
    要么你就引用类里边的常量你那么写是有语法错误的!!你要问为什么?我还真不知道怎么回答你要直接打Infinity的话你弄个引号圈起来当成个字符串来打印好了另外,Infinity这个是JAVA一个特殊的值定义呢
      

  12.   

    我也出现这种问题,
    class ExceptionProcess{
      double a[]=new double[4];
         //改为int类型,否则会在正常情况下所有结果都为0;不这样改输入0测 试,异常结果都为Infinity,怎么办啊?
       ExceptionProcess(){
        a[0]=0;
        a[1]=1;
        a[2]=2;
        a[3]=3;
      }

       void countDown(int i){  
    try{
             System.out.println(1/a[i]);
            }
    catch(ArithmeticException e){
     System.out.println("算术运算异常:"+e.getMessage());
    }
    finally{
     System.out.println("调用countDown()结束。");
    }
      }
      

  13.   

    1.Infinity只是一句话。说输出结果是个无穷大的数。
    2.Infinity告诉你结果是个无穷大数。负无穷大数输出结果是 -Infinity[比如:System.out.print(1.0/-0.0)]。浮点数有正无穷大,负无穷大
       Double.POSITIVE_INFINITY / Float.POSITIVE_INFINITY --正无穷大
       Double.NEGATIVE_INFINITY / Float.NEGATIVE_INFINITY --负无穷大
    但是你不能把Infinity当Java的literal,假如可以,那么Infinity是该表示正无穷大呢还是负无穷大?是double的正/负无穷大还是float的正/负无穷大?
      

  14.   


    首先 浮点数[float/double]有无穷大[正无穷大/负无穷大],而整数是没有无穷大的,比如int占32位,0后面31个1是最大的正数,他是有穷的
    其次 你声明一个double/int数组,数组元素的默认值是0.0 / 0
    最后 整数除以0是没意义的,要抛ArithmeticException;正浮点数除以0是正无穷大,负浮点数除以0是负无穷大,不会抛ArithmeticException
      

  15.   

    Infinity是无穷大,在java里你除0输出一下就是它了。
    还有一个比较类似的是NaN
      

  16.   

    expenceGatherDtoNew.setAgentName("Infinity");
            expenceGatherDtoNew.setBusinessNature("Infinity");
            expenceGatherDtoNew.setFourthComName("Infinity");
            expenceGatherDtoNew.setRiskCode("Infinity");
            expenceGatherDtoNew.setSecondComName("Infinity");
            expenceGatherDtoNew.setTeamName("Infinity");
    //      expenceGatherDtoNew.setThirdComName(" ");
            expenceGatherDtoNew.setUserCode("Infinity");
            expenceGatherDtoNew.setUseNature("Infinity");
            expenceGatherDtoNew.setUserName("Infinity");
            expenceGatherDtoNew.setUserType("Infinity");
            expenceGatherDtoNew.setUserTypeName("Infinity");
    导出报表里,字段输入这个是什么意思呢???