作者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
1F:推 retsamsu:temp3=(0.64).ToInt32() 08/13 22:03
3F:→ retsamsu:temp3=(0.64).ToInt32()=1 (进位了) 08/13 22:05
4F:推 mathlinka:如果你想要 temp3=0 的话,用 \ 来做除法 08/13 23:14
5F:→ mathlinka:\ 运算子: 相除并传回整数结果。 08/13 23:18
6F:推 glovev:thx 08/14 00:03
7F:→ glovev:解决了> < 08/14 00:03