mardi 28 février 2017

What's the difference between the Int() method and Math.Floor() methods in VB.NET?

I'm trying to generate positive random integers between 2 values and the MSDN lists this formula as generating random numbers between a certain range: randomValue = CInt(Math.Floor((upperbound - lowerbound + 1) * Rnd())) + lowerbound. The page later lists an example that appears to use Int() intstead of Math.Floor(): Dim value As Integer = CInt(Int((6 * Rnd()) + 1)). Is there any difference between the Int method and Math.Floor in this situation?




Aucun commentaire:

Enregistrer un commentaire