Int64Static: DivRem

DivRem

Calculates the quotient of two 64-bit signed integers and also returns the remainder in an output parameter.



 Public Function DivRem(
	  ByRef Dividend As Int64,
	  ByRef Divisor As Int64,
	  ByRef Remainder As Int64 ) As Int64

Parameters

Dividend
[ByRef] Int64. The value to be divided.
Divisor
[ByRef] Int64. The value to divide by.
Remainder
[ByRef] Int64. The remainder of the division.

Return Values

Int64 -  The integer quotient of the division.

Exceptions

ExceptionCondition
DivideByZeroException Attempt to divide by zero.

Examples

The following code will calculate the quotient and remainder of a division operation.

Public Sub Main()
    Dim x As Int64
    Dim y As Int64
    Dim q As Int64
    Dim r As Int64
    
    x = CInt64(500)
    y = CInt64(55)
    q = Int64.DivRem(x, y, r)
    
    Debug.Print CorString.Format("The quotient of {0} / {1} = {2}", x, y, q)
    Debug.Print CorString.Format("The remainder of {0} / {1} = {2}.", x, y, r)
End Sub

'This code produces the following.
'    The quotient of 500 / 55 = 9
'    The remainder of 500 / 55 = 5.

See Also

Project CorLib Overview

Class Int64Static Overview