![]() |
PCDVD數位科技討論區
(https://www.pcdvd.com.tw/index.php)
- 疑難雜症區
(https://www.pcdvd.com.tw/forumdisplay.php?f=34)
- - Microsoft Visual Basic 6.0 加法問題
(https://www.pcdvd.com.tw/showthread.php?t=664432)
|
---|
Microsoft Visual Basic 6.0 加法問題
請問各位
一個很簡單的 VB加法,程式碼如下 Dim temp As Single Private Sub Command1_Click() Label1.Caption = temp temp = temp + 0.1 End Sub 選擇在Label1裡觀看加法情形,發現有趣的情況 Command1每按一次,Label1秀出結果 依序如下 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8000001 0.9000001 1 1.1 1.2 有人可以解釋那0.000001的來歷嗎 ? 希望有高手解答 ~ :) |
因為浮點數無法精確地儲存某些數值。
http://en.wikipedia.org/wiki/Floating-point_number 引用:
|
|
所有的時間均為GMT +8。 現在的時間是10:19 PM. |
vBulletin Version 3.0.1
powered_by_vbulletin 2025。