come in
µÇ¼ | ÂÛ̳µ¼º½ -> »ªÐÂÏÊÊ -> Éç»á°Ù¿Æ | ±¾Ìû¹²ÓÐ 2 Â¥£¬·Ö 1 Ò³, µ±Ç°ÏÔʾµÚ 1 Ò³ : ±¾ÌûÊ÷ÐÎÁбí : ˢР: ·µ»ØÉÏÒ»Ò³
×÷ÕߣºÏëÄîÀÏÏç (µÈ¼¶£º2 - ³õ³ö鮣¬·¢Ìû£º160) ·¢±í£º2003-08-27 23:16:34¡¡ Â¥Ö÷¡¡ ¹Ø×¢´ËÌûÆÀ·Ö£º
²»ºÃÒâ˼£¬»¹ÏëÎÊѧ³¤¼¸¸öÎÊÌâ1¡£what is i after the following for loop? for (int i=0;i (more...)
come in
1¡£what is i after the following for loop?
for (int i=0;i<10;++i){
y+=i;
}
ΪʲĪ´ð°¸ÊÇundefined?²»Ó¦¸ÃÊÇ10Âð£¿

>> 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
ÓÐÕâÖÖд·¨Ã´£¿ ÊÇʲĪÒâ˼ÄØ£¿¼ÆËã»ú¿´µ½Õâ¸öexpressionºóÓÖÊÇÔõÑù¹¤×÷µÄ£¿

>> number % 2 == 0 is first evaluated, it may be true or false and this boolean value is then assigned to variable even. for additional knowledge check out "java operator precedence"
Put your OWN COOL signature here!
»¶Ó­À´µ½»ªÐÂÖÐÎÄÍø£¬Ó»Ô¾·¢ÌûÊÇÖ§³ÖÎÒÃǵÄ×îºÃ·½·¨!Ô­ÎÄ / ´«Í³°æ / WAP°æËùÓлظ´´ÓÕâÀïÕ¹¿ªÊÕÆðÁбí
×÷ÕߣºÏëÄîÀÏÏç (µÈ¼¶£º2 - ³õ³ö鮣¬·¢Ìû£º160) ·¢±í£º2003-08-27 23:44:41¡¡ 2Â¥ ÆÀ·Ö£º
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 ......
»¶Ó­À´µ½»ªÐÂÖÐÎÄÍø£¬Ó»Ô¾·¢ÌûÊÇÖ§³ÖÎÒÃǵÄ×îºÃ·½·¨!Ô­ÎÄ / ´«Í³°æ / WAP°æËùÓлظ´´ÓÕâÀïÕ¹¿ªÊÕÆðÁбí
ÂÛ̳µ¼º½ -> »ªÐÂÏÊÊ -> Éç»á°Ù¿Æ | ·µ»ØÉÏÒ»Ò³ | ±¾Ö÷Ìâ¹²ÓÐ 2 ƪÎÄÕ£¬·Ö 1 Ò³, µ±Ç°ÏÔʾµÚ 1 Ò³ | »Øµ½¶¥²¿
<<ʼҳ¡¡ [1]¡¡ Ä©Ò³>>

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