ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

(a + 1) «í ¤j©ó a ???

(a + 1) «í ¤j©ó a ???

¦b ¼Æ¾Ç¤W

(a + 1) «í ¤j©ó a ,
¦ý¬O¡A¥ô¦ó ¹q¸£»y¨¥¡A¥]¨í VBA

¥H¤Uªº µ{¦¡³]­p¤ù¬q

double a, b, c;

a= 1.23;
b= a + 1;

while (b > a) do begin
   a= a*1.001;
   b= a + 1;

end;
// b <= a, ???
print a, b

// why????
¤Ñ¤U¬°¤½

¦^´_ 1# sjgau


    :o  ·Qª¾¹D爲¤°»ò. ½Ð¸Ñ»¡.
ss

TOP

¦^´_ 2# sunnyso

½Ð½ç±Ð. ¬°¤°»ò©O? «Ü·Qª¾¹D.
ss

TOP

  1. Sub test1052()
  2.    Dim a As Single, b As Single
  3.    a = 1.23
  4.    b = a + 1
  5.    ' b > a
  6.    
  7.    While (b > a)
  8.       a = a * 1.001
  9.       b = a + 1
  10.       
  11.    Wend
  12.    ' b < a, why???
  13.    
  14.    Cells(3, 1) = a
  15.    Cells(4, 1) = b
  16.    ' a= b= 16781740, why???
  17.    

  18.    MsgBox ("Done!")
  19.    
  20.    
  21.    

  22. End Sub
½Æ»s¥N½X
¤Ñ¤U¬°¤½

TOP

¦^´_ 3# sunnyso

¦]¬°¡Asingle ªººÖÂI¼Æ¬O ¥|­Óbyte, 32­Óbits,
¨Ï¥Î 23­Ó bits ªí¥Ü ¼Æ¦rªººë½T«×¡A

2^23 --> no
§â 0.5 ¨ì 1.0 ¤Á³Î¦¨¬° no µ¥¤À¡A
©Ò¥H¡Aºë½T«×´N¬O 1/no
¤Ñ¤U¬°¤½

TOP

Sub test1052()
   Dim a As Double, b As Double
   a = 1.23
   b = a + 1
   ' b > a
   
   While (b > a)
      a = a * 1.001
      b = a + 1
   Wend
   ' b < a, why???
   
   Cells(3, 1) = a
   Cells(4, 1) = b
   ' a= b= 9.01577E+15, why???
   

   MsgBox ("Done!")
End Sub
¤Ñ¤U¬°¤½

TOP

¦pªG¬O ¡Adouble ªººÖÂI¼Æ¬O ¤K­Óbyte, 64­Óbits,
¨Ï¥Î 52­Ó bits ªí¥Ü ¼Æ¦rªººë½T«×¡A

2^53 --> no
§â 0.5 ¨ì 1.0 ¤Á³Î¦¨¬° no µ¥¤À¡A
©Ò¥H¡Aºë½T«×´N¬O 1/no
¤Ñ¤U¬°¤½

TOP

¦^´_ 3# sunnyso
§A¥i¥H¥ý·Q·Q Single ¥u¦³32¦ì¤¸¬°¦ó³Ì¤j¥iªí¥Ü¨ì 3.402823E38¡C
¥i°Ñ¦Ò IEEE 754  http://zh.wikipedia.org/wiki/IEEE_754

TOP

·PÁ¤T¦ì¤j¤j¼ö¤ß¸Ñ»¡. «Ü¨ü±Ð
ss

TOP

¦^´_ 9# sunnyso


    ¤]¥i¥H¹L¥h ¥»°Q½×°Ï
C»y¨¥µ{¦¡³]­pªOªO ¬Ý¬Ý
¤Ñ¤U¬°¤½

TOP

        ÀR«ä¦Û¦b : ­n¤ñ½Ö§ó¨ü½Ö¡D¤£­n¤ñ½Ö§ó©È½Ö¡C
ªð¦^¦Cªí ¤W¤@¥DÃD