Mega Code Archive

 
Categories / VB.Net / Development
 

Math DivRem calculates the quotient of two integers and returns the remainder in an output parameter

Module Example    Public Sub Main()       Dim dividends() As Long = { Int64.MaxValue, 2010, 0, -2010, Int64.MinValue }       Dim divisors() As Long = { 2000, -2000 }       For Each divisor As Long In divisors          For Each dividend As Long In dividends             Dim remainder As Long              Dim quotient As Long = Math.DivRem(dividend, divisor, remainder)             Console.WriteLine("{0:N0} \ {1:N0} = {2:N0}, remainder {3:N0}", _                               dividend, divisor, quotient, remainder)          Next       Next                                    End Sub End Module