作者glovev (阿章)
看板Visual_Basic
標題[.NET] 奇怪的數值問題
時間Mon Aug 13 21:53:44 2007
Public Sub caraction(ByVal steps As Integer, ByVal character As String)
Dim temp5, temp4, temp3, temp2, temp1, a, b, c, d, e As Integer
temp5 = steps / 10000
a = steps Mod 10000
temp4 = a / 1000
b = a Mod 1000
temp3 = b / 100
c = b Mod 100
temp2 = c / 10
temp1 = c Mod 10
假如我的steps是64的話
會得到temp5=0 temp4=0
temp3=1 temp2=6 temp1=4
位什麼會出現這麼奇怪的結果?
煩請大家幫忙一下摟,謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.121.135.238
推 retsamsu:temp3=(0.64).ToInt32() 08/13 22:03
→ retsamsu:temp3=(0.64).ToInt32()=1 (進位了) 08/13 22:05
推 mathlinka:如果你想要 temp3=0 的話,用 \ 來做除法 08/13 23:14
→ mathlinka:\ 運算子: 相除並傳回整數結果。 08/13 23:18
推 glovev:thx 08/14 00:03
→ glovev:解決了> < 08/14 00:03