我想知道在VB.NET中检查可除性的最快方法是什么。
我尝试了以下两个函数,但感觉还有更有效率的技巧。
Function isDivisible(x As Integer, d As Integer) As Boolean
Return Math.floor(x / d) = x / d
End Function
我想到了另一个方案:
Function isDivisible(x As Integer, d As Integer) As Boolean
Dim v = x / d
Dim w As Integer = v
Return v = w
End Function
这是一种更实用的方式吗?