本文整理匯總了VB.NET中System.Math.DivRem方法的典型用法代碼示例。如果您正苦於以下問題:VB.NET Math.DivRem方法的具體用法?VB.NET Math.DivRem怎麽用?VB.NET Math.DivRem使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Math
的用法示例。
在下文中一共展示了Math.DivRem方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: Example
Module Example
Public Sub Main()
' Define several positive and negative dividends.
Dim dividends() As Integer = { Int32.MaxValue, 13952, 0, -14032, _
Int32.MinValue }
' Define one positive and one negative divisor.
Dim divisors() As Integer = { 2000, -2000 }
For Each divisor As Integer In divisors
For Each dividend As Integer In dividends
Dim remainder As Integer
Dim quotient As Integer = 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
輸出:
2,147,483,647 \ 2,000 = 1,073,741, remainder 1,647 13,952 \ 2,000 = 6, remainder 1,952 0 \ 2,000 = 0, remainder 0 -14,032 \ 2,000 = -7, remainder -32 -2,147,483,648 \ 2,000 = -1,073,741, remainder -1,648 2,147,483,647 \ -2,000 = -1,073,741, remainder 1,647 13,952 \ -2,000 = -6, remainder 1,952 0 \ -2,000 = 0, remainder 0 -14,032 \ -2,000 = 7, remainder -32 -2,147,483,648 \ -2,000 = 1,073,741, remainder -1,648
示例2: Example
Module Example
Public Sub Main()
' Define several positive and negative dividends.
Dim dividends() As Long = { Int64.MaxValue, 13952, 0, -14032, _
Int64.MinValue }
' Define one positive and one negative divisor.
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
輸出:
9,223,372,036,854,775,807 \ 2,000 = 4,611,686,018,427,387, remainder 1,807 13,952 \ 2,000 = 6, remainder 1,952 0 \ 2,000 = 0, remainder 0 -14,032 \ 2,000 = -7, remainder -32 -9,223,372,036,854,775,808 \ 2,000 = -4,611,686,018,427,387, remainder -1,808 9,223,372,036,854,775,807 \ -2,000 = -4,611,686,018,427,387, remainder 1,807 13,952 \ -2,000 = -6, remainder 1,952 0 \ -2,000 = 0, remainder 0 -14,032 \ -2,000 = 7, remainder -32 -9,223,372,036,854,775,808 \ -2,000 = 4,611,686,018,427,387, remainder -1,808