double d = 10.00;
System.out.println((d - (int)d)==(double)0.0);

解决方案 »

  1.   

    奇怪了,skyyoung(路人甲)说错了吗?
    不好意思,呵呵
    恐怕笨蛋不是他呀
      

  2.   

    这位高手请指教,我说的是Double类,前面是大写耶.
    你是高手请指教.
      

  3.   

    Double dd = Double(10.02);
    double d = dd.doubleValue();
    System.out.println((d - (int)d)==(double)0.0); 笨蛋你不会转换吗!?
      

  4.   

    Double dd = new Double(10.02);Convert from type X to type Y
    integer to String :    int i = 42;
       String str = Integer.toString(i);
       or
       String str = "" + i
     
    double to String :   String str = Double.toString(i);
     
    long to String :   String str = Long.toString(l);
     
    float to String :   String str = Float.toString(f);
     String to integer :   str = "25";
       int i = Integer.valueOf(str).intValue();
       or
       int i = Integer.parseInt(str);
     
    String to double :   double d = Double.valueOf(str).doubleValue();
     
    String to long :   long l = Long.valueOf(str).longValue();
       or
       long l = Long.parseLong(str);
     
    String to float :   float f = Float.valueOf(str).floatValue();
     decimal to binary :   int i = 42;
       String binstr = Integer.toBinaryString(i);
     decimal to hexadecimal :   int i = 42;
       String hexstr = Integer.toString(i, 16);
       or
       String hexstr = Integer.toHexString(i);
     hexadecimal (String) to integer :   int i = Integer.valueOf("B8DA3", 16).intValue();
       or
       int i = Integer.parseInt("B8DA3", 16);     
     
    ASCII code to String   int i = 64;
       String aChar = new Character((char)i).toString();
     integer to ASCII code (byte)   char c = 'A';
       int i = (int) c; // i will have the value 65 decimal
     To extract Ascii codes from a String     String test = "ABCD";
         for ( int i = 0; i < test.length(); ++i ) {
           char c = test.charAt( i );
           int i = (int) c;
           System.out.println(i);
           }
     integer to boolean   b = (i != 0);
     
    boolean to integer   i = (b)?1:0;
     
    note :To catch illegal number conversion, try using the try/catch mechanism. try{
      i = Integer.parseInt(aString);
      }
    catch(NumberFormatException e)
      {
      } 
      

  5.   

    路人甲还是你好,小红帽菜鸟老瞎说,我们俩不理他.
    不过我听说,double型不能用"==",因为它计算所得
    的结果一般不等于0,而是0.0000000000几,只能用
    "<"或">"来确定,不是真是假,请您再确认以下.
      

  6.   

    double d = 0.000;
    double dd = 0.00;
    System.out.println(d==dd);
    System.out.println(d==0);Result:
    true
    true
      

  7.   

    double d = 0.000;
        double dd = 0;
        d = 12.49367 - 10.29367;    
        int decimalPlace = 5;
        BigDecimal bd = new BigDecimal(d);    
        bd = bd.setScale(decimalPlace,BigDecimal.ROUND_HALF_UP);
        d = bd.doubleValue();    
        System.out.println(d);
      

  8.   

    BigDecimal,我是新学的,能不能给我讲解一下他的用法
      

  9.   

    In C++, or Computer Science text book, it is true that two foalts cannot be compared as "equal". Java allows to do so, but I am not sure it is a good idea. The way I do it is simple:Double dbl = new Double(10.2);
    Double db2 = new Double(dbl.intValue());
    if (dbl1.equals(db2))
    {
     //yes
    }
    {
    //no
    }I haven't checked the implementation of Double.equals, but I think it will use Native function to convert doubles to longs (float's binary presentation), then compare two longs.By the way, to cq4550: 路人甲 is not a 笨蛋. He is a great helper.
      

  10.   

    是的,小丫头,打听清楚先,
    路人甲 is very very good!
    以后再这样说别人,当心打你屁股。
      

  11.   

    就是就是,而且是脱了裤子打哦,呵呵路人甲is very good
      

  12.   

    我靠,你们想占人家女孩子的便宜啊,我靠,java帮全是狼
      

  13.   

    这个问题得先搞清楚你所谓的整数是什么意思!
    Double d1=new Double(10.00);
    Double d2=new Double(10);
    从你的需要来看,d1算吗?