André said:
Thanks
"Theo Verweij" <
[email protected]> schreef in bericht
If x/y = x\y then
'Is an integer
else
'is not
end if
I would actually use Mod (modulus) to determine if a division result
(remainder) is 0.
Example:
Dim x As Integer = 12
Dim y As Integer = 6
Dim isInt As Boolean = x Mod y = 0
Console.WriteLine( _
"Remainder of {0} / {1} = {2} : Integral = {3}", _
x.ToString(), _
y.ToString(), _
(x / y).ToString(), _
(x Mod y = 0).ToString() _
)
The last parameter (x Mod y = 0) is the part that I would use
So:
If x Mod y = 0 Then
' x / y results in a 0 remainder, meaning an int result (given that the
result falls within the scope of an integer and not a long.
Else
' x / y results in a non-0 remainder, meaning a floating point result.
End If
HTH
Mythran