²»ºÃÒâ˼£¬»¹ÏëÎÊѧ³¤¼¸¸öÎÊÌâ
µÇ¼ | ÂÛ̳µ¼º½ -> »ªÐÂÏÊÊ -> Éç»á°Ù¿Æ | ±¾Ìû¹²ÓÐ 7 Â¥£¬µ±Ç°ÏÔʾµÚ 6 Â¥ : ´ÓÂ¥Ö÷¿ªÊ¼ÔĶÁ : ±¾ÌûÊ÷ÐÎÁбí : ·µ»ØÉÏÒ»Ò³
×÷ÕߣºÏëÄîÀÏÏç (µÈ¼¶£º2 - ³õ³ö鮣¬·¢Ìû£º160) ·¢±í£º2003-08-27 23:44:41¡¡ 6Â¥¡¡ ÆÀ·Ö£º¡¡
come in1¡£what is i after the following for loop? for (int i=0;i> i is only defined within the for loop structure 2¡£analyze the following fragment: double sum=0; double d=0; while(d!=10.0){ d+=0.1; sum+=sum+d; } ´ð°¸£ºthe program may not stop because of the phenomenon referred t as numerical inaccuracy for uperating with floating-pointing numbers. Ϊɶ£¿²»¶®~~~~ >> floating number is represented in IEEE 754 standards, it means that for any number of float type in java, the system keeps only the first 23 bit after decimal point and thus there is some error in magnitude....just search on google use IEEE 754 to find out more details 3¡£analyze the following code: boolean even=false; if(even=true){ system.out.println(" it is even!"); } дµÃÓдíÂ𣿽á¹ûÊÇʲĪ£¿ >>true is first assign to variable even, and then the value of variable even is evaluated (it's true by now). >> = is not equivalent to == , the first one is assignment and the second is comparison.... 4¡£even=number%2==0 ÓÐÕâÖÖд·¨Ã´£¿ ÊÇʲĪÒâË¼Ä (more...)
for 2, more details here
sorry for my careless mistake you are actually using double here which is 64 bits in java, but the argument is the same. you can use the following program to find out what exactly happens:

class T {

public static void main (String args[]) {
double d = 0;
for(; d < 10.1; d += 0.1){
if(d > 9.8){
System.out.print(Long.toBinaryString(Double.doubleToLongBits(d))+" == >"+d+"\n");
}
}

System.out.print("\n\n"+Long.toBinaryString(Double.doubleToLongBits(10))+" == >10\n");
}
}


The output is like:

100000000100011110011001100110011001100110011001100110011000010 == >9.89999999999998
100000000100011111111111111111111111111111111111111111111110101 == >9.99999999999998
100000000100100001100110011001100110011001100110011001100101000 == >10.09999999999998


100000000100100000000000000000000000000000000000000000000000000 == >10


so ......
Put your OWN COOL signature here!
»¶Ó­À´µ½»ªÐÂÖÐÎÄÍø£¬Ó»Ô¾·¢ÌûÊÇÖ§³ÖÎÒÃǵÄ×îºÃ·½·¨!Ô­ÎÄ / ´«Í³°æ / WAP°æÖ»¿´´ËÈË´ÓÕâÀïÕ¹¿ªÊÕÆðÁбí

±¾Ìû¹²ÓÐ 7 Â¥£¬µ±Ç°ÏÔʾµÚ 6 Â¥£¬±¾ÎÄ»¹ÓÐ N-1 ²ãÂ¥£¬Òª²»ÄãÊÔÊÔ¿´£ºµã»÷´Ë´¦ÔĶÁ¸ü¶à >>



ÇëµÇ¼ºó»Ø¸´£ºÕʺŠ¡¡ ÃÜÂë ¡¡