
正文
包含VbNetint的词条
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
vb.net中的int重载问题
int(x)函数是取不大于x的最大整数。
如果你
Dim A As Double = 180.8931 * 10000
那么
Trace.WriteLine(A) '输出A为1808931
A = Int(A)
Trace.WriteLine(A) '输出A为1808931
而你是:
Dim A As Double = 180.89305 * 10000+0.5
是乘后再加的0.5
在Int时就会
Trace.WriteLine(int(A)) '输出A为1808930
相当于int(180.89305 * 10000+0.5)而不是:int(1808931)。
相关问答
Q1: vb.net中的int
Dim n As Integer = Integer.Parse(Command.ExecuteScalar("select count(sno) from student").ToString())
ExecuteScalar 返回的是 object 类型
Q2: vb.net中 int函数和math.Truncate 都是取整有什么区别
int在绝对值上四舍五入,Truncate在靠近0的方向取整,比如:
Sub Main()
Dim d = -1.9D
'Dim I As Integer = Int(d) '-2
Dim I As Integer = Math.Truncate(d) '-1
Console.WriteLine(I)
Console.ReadLine()
End Sub
VbNetint的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于、VbNetint的信息别忘了在本站进行查找喔。






