Math.DivRem Metoda
Definice
Důležité
Některé informace platí pro předběžně vydaný produkt, který se může zásadně změnit, než ho výrobce nebo autor vydá. Microsoft neposkytuje žádné záruky, výslovné ani předpokládané, týkající se zde uváděných informací.
Vypočítá podíl dvou čísel a vrátí zbytek ve výstupním parametru.
Přetížení
DivRem(IntPtr, IntPtr) |
Vytvoří podíl a zbytek dvou čísel nativní velikosti se znaménkem. |
DivRem(Int64, Int64, Int64) |
Vypočítá podíl dvou 64bitových celých čísel se znaménkem a vrátí zbytek ve výstupním parametru. |
DivRem(Int32, Int32, Int32) |
Vypočítá podíl dvou 32bitových celých čísel se znaménkem a vrátí zbytek ve výstupním parametru. |
DivRem(UIntPtr, UIntPtr) |
Vytvoří podíl a zbytek dvou čísel nativní velikosti bez znaménka. |
DivRem(UInt64, UInt64) |
Vytvoří podíl a zbytek dvou 64bitových čísel bez znaménka. |
DivRem(UInt32, UInt32) |
Vytvoří podíl a zbytek dvou 32bitových čísel bez znaménka. |
DivRem(Int64, Int64) |
Vytvoří podíl a zbytek dvou 64bitových čísel se znaménkem. |
DivRem(SByte, SByte) |
Vytvoří podíl a zbytek dvou 8bitových čísel se znaménkem. |
DivRem(Int32, Int32) |
Vytvoří podíl a zbytek dvou 32bitových čísel se znaménkem. |
DivRem(Int16, Int16) |
Vytvoří podíl a zbytek dvou 16bitových čísel se znaménkem. |
DivRem(Byte, Byte) |
Vytvoří podíl a zbytek dvou 8bitových čísel bez znaménka. |
DivRem(UInt16, UInt16) |
Vytvoří podíl a zbytek dvou 16bitových čísel bez znaménka. |
DivRem(IntPtr, IntPtr)
Vytvoří podíl a zbytek dvou čísel nativní velikosti se znaménkem.
public:
static ValueTuple<IntPtr, IntPtr> DivRem(IntPtr left, IntPtr right);
public static (IntPtr,IntPtr) DivRem (IntPtr left, IntPtr right);
static member DivRem : nativeint * nativeint -> ValueTuple<nativeint, nativeint>
Public Shared Function DivRem (left As IntPtr, right As IntPtr) As ValueTuple(Of IntPtr, IntPtr)
Parametry
- left
-
IntPtr
nativeint
Dividenda.
- right
-
IntPtr
nativeint
Dělitel.
Návraty
-
ValueTuple<nativeint,nativeint>
Podíl a zbytek zadaných čísel.
Platí pro
DivRem(Int64, Int64, Int64)
Vypočítá podíl dvou 64bitových celých čísel se znaménkem a vrátí zbytek ve výstupním parametru.
public:
static long DivRem(long a, long b, [Runtime::InteropServices::Out] long % result);
public static long DivRem (long a, long b, out long result);
static member DivRem : int64 * int64 * int64 -> int64
Public Shared Function DivRem (a As Long, b As Long, ByRef result As Long) As Long
Parametry
- a
- Int64
Dividenda.
- b
- Int64
Dělitel.
- result
- Int64
Když se tato metoda vrátí, obsahuje zbytek.
Návraty
Podíl zadaných čísel
Výjimky
b
je nula.
Příklady
Následující příklad ukazuje DivRem(Int64, Int64, Int64) metodu .
using System;
public class Example
{
public static void Main()
{
// Define several positive and negative dividends.
long[] dividends = { Int64.MaxValue, 13952, 0, -14032,
Int64.MinValue };
// Define one positive and one negative divisor.
long[] divisors = { 2000, -2000 };
foreach (long divisor in divisors)
{
foreach (long dividend in dividends)
{
long remainder;
long quotient = Math.DivRem(dividend, divisor, out remainder);
Console.WriteLine(@"{0:N0} \ {1:N0} = {2:N0}, remainder {3:N0}",
dividend, divisor, quotient, remainder);
}
}
}
}
// The example displays the following output:
// 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
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
' The example displays the following output:
' 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
Poznámky
Zbývající hodnota se rovná výsledku operátoru zbytku.
Viz také
Platí pro
DivRem(Int32, Int32, Int32)
Vypočítá podíl dvou 32bitových celých čísel se znaménkem a vrátí zbytek ve výstupním parametru.
public:
static int DivRem(int a, int b, [Runtime::InteropServices::Out] int % result);
public static int DivRem (int a, int b, out int result);
static member DivRem : int * int * int -> int
Public Shared Function DivRem (a As Integer, b As Integer, ByRef result As Integer) As Integer
Parametry
- a
- Int32
Dividenda.
- b
- Int32
Dělitel.
- result
- Int32
Když se tato metoda vrátí, obsahuje zbytek.
Návraty
Podíl zadaných čísel
Výjimky
b
je nula.
Příklady
Následující příklad ukazuje DivRem(Int32, Int32, Int32) metodu .
using System;
public class Example
{
public static void Main()
{
// Define several positive and negative dividends.
int[] dividends = { Int32.MaxValue, 13952, 0, -14032,
Int32.MinValue };
// Define one positive and one negative divisor.
int[] divisors = { 2000, -2000 };
foreach (int divisor in divisors)
{
foreach (int dividend in dividends)
{
int remainder;
int quotient = Math.DivRem(dividend, divisor, out remainder);
Console.WriteLine(@"{0:N0} \ {1:N0} = {2:N0}, remainder {3:N0}",
dividend, divisor, quotient, remainder);
}
}
}
}
// The example displays the following output:
// 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
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
' The example displays the following output:
' 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
Poznámky
Zbývající hodnota se rovná výsledku operátoru zbytku.
Viz také
Platí pro
DivRem(UIntPtr, UIntPtr)
Důležité
Toto rozhraní API neodpovídá specifikaci CLS.
Vytvoří podíl a zbytek dvou čísel nativní velikosti bez znaménka.
public:
static ValueTuple<UIntPtr, UIntPtr> DivRem(UIntPtr left, UIntPtr right);
[System.CLSCompliant(false)]
public static (UIntPtr,UIntPtr) DivRem (UIntPtr left, UIntPtr right);
public static (UIntPtr,UIntPtr) DivRem (UIntPtr left, UIntPtr right);
[<System.CLSCompliant(false)>]
static member DivRem : unativeint * unativeint -> ValueTuple<unativeint, unativeint>
static member DivRem : unativeint * unativeint -> ValueTuple<unativeint, unativeint>
Public Shared Function DivRem (left As UIntPtr, right As UIntPtr) As ValueTuple(Of UIntPtr, UIntPtr)
Parametry
- left
-
UIntPtr
unativeint
Dividenda.
- right
-
UIntPtr
unativeint
Dělitel.
Návraty
-
ValueTuple<unativeint,unativeint>
Podíl a zbytek zadaných čísel.
- Atributy
Platí pro
DivRem(UInt64, UInt64)
Důležité
Toto rozhraní API neodpovídá specifikaci CLS.
Vytvoří podíl a zbytek dvou 64bitových čísel bez znaménka.
public:
static ValueTuple<System::UInt64, System::UInt64> DivRem(System::UInt64 left, System::UInt64 right);
[System.CLSCompliant(false)]
public static (ulong,ulong) DivRem (ulong left, ulong right);
public static (ulong,ulong) DivRem (ulong left, ulong right);
[<System.CLSCompliant(false)>]
static member DivRem : uint64 * uint64 -> ValueTuple<uint64, uint64>
static member DivRem : uint64 * uint64 -> ValueTuple<uint64, uint64>
Public Shared Function DivRem (left As ULong, right As ULong) As ValueTuple(Of ULong, ULong)
Parametry
- left
- UInt64
Dividenda.
- right
- UInt64
Dělitel.
Návraty
Podíl a zbytek zadaných čísel.
- Atributy
Platí pro
DivRem(UInt32, UInt32)
Důležité
Toto rozhraní API neodpovídá specifikaci CLS.
Vytvoří podíl a zbytek dvou 32bitových čísel bez znaménka.
public:
static ValueTuple<System::UInt32, System::UInt32> DivRem(System::UInt32 left, System::UInt32 right);
[System.CLSCompliant(false)]
public static (uint,uint) DivRem (uint left, uint right);
public static (uint,uint) DivRem (uint left, uint right);
[<System.CLSCompliant(false)>]
static member DivRem : uint32 * uint32 -> ValueTuple<uint32, uint32>
static member DivRem : uint32 * uint32 -> ValueTuple<uint32, uint32>
Public Shared Function DivRem (left As UInteger, right As UInteger) As ValueTuple(Of UInteger, UInteger)
Parametry
- left
- UInt32
Dividenda.
- right
- UInt32
Dělitel.
Návraty
Podíl a zbytek zadaných čísel.
- Atributy
Platí pro
DivRem(Int64, Int64)
Vytvoří podíl a zbytek dvou 64bitových čísel se znaménkem.
public:
static ValueTuple<long, long> DivRem(long left, long right);
public static (long,long) DivRem (long left, long right);
static member DivRem : int64 * int64 -> ValueTuple<int64, int64>
Public Shared Function DivRem (left As Long, right As Long) As ValueTuple(Of Long, Long)
Parametry
- left
- Int64
Dividenda.
- right
- Int64
Dělitel.
Návraty
Podíl a zbytek zadaných čísel.
Platí pro
DivRem(SByte, SByte)
Důležité
Toto rozhraní API neodpovídá specifikaci CLS.
Vytvoří podíl a zbytek dvou 8bitových čísel se znaménkem.
public:
static ValueTuple<System::SByte, System::SByte> DivRem(System::SByte left, System::SByte right);
[System.CLSCompliant(false)]
public static (sbyte,sbyte) DivRem (sbyte left, sbyte right);
public static (sbyte,sbyte) DivRem (sbyte left, sbyte right);
[<System.CLSCompliant(false)>]
static member DivRem : sbyte * sbyte -> ValueTuple<sbyte, sbyte>
static member DivRem : sbyte * sbyte -> ValueTuple<sbyte, sbyte>
Public Shared Function DivRem (left As SByte, right As SByte) As ValueTuple(Of SByte, SByte)
Parametry
- left
- SByte
Dividenda.
- right
- SByte
Dělitel.
Návraty
Podíl a zbytek zadaných čísel.
- Atributy
Platí pro
DivRem(Int32, Int32)
Vytvoří podíl a zbytek dvou 32bitových čísel se znaménkem.
public:
static ValueTuple<int, int> DivRem(int left, int right);
public static (int,int) DivRem (int left, int right);
static member DivRem : int * int -> ValueTuple<int, int>
Public Shared Function DivRem (left As Integer, right As Integer) As ValueTuple(Of Integer, Integer)
Parametry
- left
- Int32
Dividenda.
- right
- Int32
Dělitel.
Návraty
Podíl a zbytek zadaných čísel.
Platí pro
DivRem(Int16, Int16)
Vytvoří podíl a zbytek dvou 16bitových čísel se znaménkem.
public:
static ValueTuple<short, short> DivRem(short left, short right);
public static (short,short) DivRem (short left, short right);
static member DivRem : int16 * int16 -> ValueTuple<int16, int16>
Public Shared Function DivRem (left As Short, right As Short) As ValueTuple(Of Short, Short)
Parametry
- left
- Int16
Dividenda.
- right
- Int16
Dělitel.
Návraty
Podíl a zbytek zadaných čísel.
Platí pro
DivRem(Byte, Byte)
Vytvoří podíl a zbytek dvou 8bitových čísel bez znaménka.
public:
static ValueTuple<System::Byte, System::Byte> DivRem(System::Byte left, System::Byte right);
public static (byte,byte) DivRem (byte left, byte right);
static member DivRem : byte * byte -> ValueTuple<byte, byte>
Public Shared Function DivRem (left As Byte, right As Byte) As ValueTuple(Of Byte, Byte)
Parametry
- left
- Byte
Dividenda.
- right
- Byte
Dělitel.
Návraty
Podíl a zbytek zadaných čísel.
Platí pro
DivRem(UInt16, UInt16)
Důležité
Toto rozhraní API neodpovídá specifikaci CLS.
Vytvoří podíl a zbytek dvou 16bitových čísel bez znaménka.
public:
static ValueTuple<System::UInt16, System::UInt16> DivRem(System::UInt16 left, System::UInt16 right);
[System.CLSCompliant(false)]
public static (ushort,ushort) DivRem (ushort left, ushort right);
public static (ushort,ushort) DivRem (ushort left, ushort right);
[<System.CLSCompliant(false)>]
static member DivRem : uint16 * uint16 -> ValueTuple<uint16, uint16>
static member DivRem : uint16 * uint16 -> ValueTuple<uint16, uint16>
Public Shared Function DivRem (left As UShort, right As UShort) As ValueTuple(Of UShort, UShort)
Parametry
- left
- UInt16
Dividenda.
- right
- UInt16
Dělitel.
Návraty
Podíl a zbytek zadaných čísel.
- Atributy