Freigeben über


Math.IEEERemainder-Methode

Gibt den Rest der Division zweier angegebener Zahlen zurück.

Namespace: System
Assembly: mscorlib (in mscorlib.dll)

Syntax

'Declaration
Public Shared Function IEEERemainder ( _
    x As Double, _
    y As Double _
) As Double
'Usage
Dim x As Double
Dim y As Double
Dim returnValue As Double

returnValue = Math.IEEERemainder(x, y)
public static double IEEERemainder (
    double x,
    double y
)
public:
static double IEEERemainder (
    double x, 
    double y
)
public static double IEEERemainder (
    double x, 
    double y
)
public static function IEEERemainder (
    x : double, 
    y : double
) : double

Parameter

  • x
    Ein Dividend.
  • y
    Ein Divisor.

Rückgabewert

Die Zahl x - (yQ), wobei Q der auf die nächste ganze Zahl gerundete Quotient x/y ist (wenn x/y genau in der Mitte zwischen zwei ganzen Zahlen liegt, wird die gerade ganze Zahl verwendet). Wenn x - (yQ) gleich 0 ist, wird bei positivem x +0 und bei negativem x -0 zurückgegeben. Wenn y gleich 0 (null) ist, wird NaN (Not-A-Number) zurückgegeben.

Hinweise

Diese Operation ist mit der Restoperation kompatibel, die in Abschnitt 5.1 des ANSI/IEEE-Standards 754-1985, IEEE Standard for Binary Floating-Point Arithmetic, Institute of Electrical and Electronics Engineers, Inc., 1985, definiert ist.

Beispiel

' This example demonstrates Math.DivRem()
'                           Math.IEEERemainder()
Imports System

Class Sample
   Public Shared Sub Main()
      Dim int1 As Integer = Int32.MaxValue
      Dim int2 As Integer = Int32.MaxValue
      Dim intResult As Integer
      Dim long1 As Long = Int64.MaxValue
      Dim long2 As Long = Int64.MaxValue
      Dim longResult As Long
      Dim doubleResult As Double
      Dim divisor As Double
      Dim nl As [String] = Environment.NewLine
      '
      Console.WriteLine("{0}Calculate the quotient and remainder of two Int32 values:", nl)
      intResult = Math.DivRem(int1, 2, int2)
      Console.WriteLine("{0}/{1} = {2}, with a remainder of {3}.", int1, 2, intResult, int2)
      '
      Console.WriteLine("{0}Calculate the quotient and remainder of two Int64 values:", nl)
      longResult = Math.DivRem(long1, 4, long2)
      Console.WriteLine("{0}/{1} = {2}, with a remainder of {3}.", long1, 4, longResult, long2)
      '
      Dim str1 As [String] = "The IEEE remainder of {0:e}/{1:f} is {2:e}"
      divisor = 2.0
      Console.WriteLine("{0}Divide two double-precision floating-point values:", nl)
      doubleResult = Math.IEEERemainder([Double].MaxValue, divisor)
      Console.Write("1) ")
      Console.WriteLine(str1, [Double].MaxValue, divisor, doubleResult)
      
      divisor = 3.0
      doubleResult = Math.IEEERemainder([Double].MaxValue, divisor)
      Console.Write("2) ")
      Console.WriteLine(str1, [Double].MaxValue, divisor, doubleResult)
      Console.WriteLine("Note that two positive numbers can yield a negative remainder.")
   End Sub 'Main
End Class 'Sample
'
'This example produces the following results:
'
'Calculate the quotient and remainder of two Int32 values:
'2147483647/2 = 1073741823, with a remainder of 1.
'
'Calculate the quotient and remainder of two Int64 values:
'9223372036854775807/4 = 2305843009213693951, with a remainder of 3.
'
'Divide two double-precision floating-point values:
'1) The IEEE remainder of 1.797693e+308/2.00 is 0.000000e+000
'2) The IEEE remainder of 1.797693e+308/3.00 is -1.000000e+000
'Note that two positive numbers can yield a negative remainder.
'
// This example demonstrates Math.DivRem()
//                           Math.IEEERemainder()
using System;

class Sample 
{
    public static void Main() 
    {
    int int1 = Int32.MaxValue;
    int int2 = Int32.MaxValue;
    int intResult;
    long long1 = Int64.MaxValue;
    long long2 = Int64.MaxValue;
    long longResult;
    double doubleResult;
    double divisor;
    String nl = Environment.NewLine;
//
    Console.WriteLine("{0}Calculate the quotient and remainder of two Int32 values:", nl);
    intResult = Math.DivRem(int1, 2, out int2);
    Console.WriteLine("{0}/{1} = {2}, with a remainder of {3}.", int1, 2, intResult, int2);
//
    Console.WriteLine("{0}Calculate the quotient and remainder of two Int64 values:", nl);
    longResult = Math.DivRem(long1, 4, out long2);
    Console.WriteLine("{0}/{1} = {2}, with a remainder of {3}.", long1, 4, longResult, long2);
//
    String str1 = "The IEEE remainder of {0:e}/{1:f} is {2:e}";
    divisor = 2.0;
    Console.WriteLine("{0}Divide two double-precision floating-point values:", nl);
    doubleResult = Math.IEEERemainder(Double.MaxValue, divisor);
    Console.Write("1) ");
    Console.WriteLine(str1, Double.MaxValue, divisor, doubleResult);

    divisor = 3.0;
    doubleResult = Math.IEEERemainder(Double.MaxValue, divisor);
    Console.Write("2) ");
    Console.WriteLine(str1, Double.MaxValue, divisor, doubleResult);
    Console.WriteLine("Note that two positive numbers can yield a negative remainder.");
    }
}
/*
This example produces the following results:

Calculate the quotient and remainder of two Int32 values:
2147483647/2 = 1073741823, with a remainder of 1.

Calculate the quotient and remainder of two Int64 values:
9223372036854775807/4 = 2305843009213693951, with a remainder of 3.

Divide two double-precision floating-point values:
1) The IEEE remainder of 1.797693e+308/2.00 is 0.000000e+000
2) The IEEE remainder of 1.797693e+308/3.00 is -1.000000e+000
Note that two positive numbers can yield a negative remainder.

*/
// This example demonstrates Math.DivRem()
//                           Math.IEEERemainder()
using namespace System;
int main()
{
   int int1 = Int32::MaxValue;
   int int2 = Int32::MaxValue;
   int intResult;
   Int64 long1 = Int64::MaxValue;
   Int64 long2 = Int64::MaxValue;
   Int64 longResult;
   double doubleResult;
   double divisor;
   String^ nl = Environment::NewLine;
   
   //
   Console::WriteLine( "{0}Calculate the quotient and remainder of two Int32 values:", nl );
   intResult = Math::DivRem( int1, 2, int2 );
   Console::WriteLine( "{0}/{1} = {2}, with a remainder of {3}.", int1, 2, intResult, int2 );
   
   //
   Console::WriteLine( "{0}Calculate the quotient and remainder of two Int64 values:", nl );
   longResult = Math::DivRem( long1, 4, long2 );
   Console::WriteLine( "{0}/{1} = {2}, with a remainder of {3}.", long1, 4, longResult, long2 );
   
   //
   String^ str1 = "The IEEE remainder of {0:e}/{1:f} is {2:e}";
   divisor = 2.0;
   Console::WriteLine( "{0}Divide two double-precision floating-point values:", nl );
   doubleResult = Math::IEEERemainder( Double::MaxValue, divisor );
   Console::Write( "1) " );
   Console::WriteLine( str1, Double::MaxValue, divisor, doubleResult );
   divisor = 3.0;
   doubleResult = Math::IEEERemainder( Double::MaxValue, divisor );
   Console::Write( "2) " );
   Console::WriteLine( str1, Double::MaxValue, divisor, doubleResult );
   Console::WriteLine( "Note that two positive numbers can yield a negative remainder." );
}

/*
This example produces the following results:

Calculate the quotient and remainder of two Int32 values:
2147483647/2 = 1073741823, with a remainder of 1.

Calculate the quotient and remainder of two Int64 values:
9223372036854775807/4 = 2305843009213693951, with a remainder of 3.

Divide two double-precision floating-point values:
1) The IEEE remainder of 1.797693e+308/2.00 is 0.000000e+000
2) The IEEE remainder of 1.797693e+308/3.00 is -1.000000e+000
Note that two positive numbers can yield a negative remainder.
*/
// This example demonstrates Math.DivRem()
// Math.IEEERemainder()
import System.*;

class Sample
{
    public static void main(String[] args)
    {
        int int1 = Int32.MaxValue;
        int int2 = Int32.MaxValue;
        int intResult;
        long long1 = Int64.MaxValue;
        long long2 = Int64.MaxValue;
        long longResult;
        double doubleResult;
        double divisor;
        String nl = Environment.get_NewLine();
        //
        Console.WriteLine("{0}Calculate the quotient and " 
            + "remainder of two Int32 values:", nl);
        intResult = System.Math.DivRem(int1, 2, int2);
        Console.WriteLine("{0}/{1} = {2}, with a remainder of {3}.", 
            new Object[] { (Int32)int1, (Int32)2,
            (Int32)intResult, (Int32)int2 });
        //
        Console.WriteLine("{0}Calculate the quotient and remainder" 
            + " of two Int64 values:", nl);
        longResult = System.Math.DivRem(long1, 4, long2);
        Console.WriteLine("{0}/{1} = {2}, with a remainder of {3}.", 
            new Object[] { (Int64)long1, (Int32)4, 
            (Int64)longResult, (Int64)long2    });
        //
        String str1 = "The IEEE remainder of {0:e}/{1:f} is {2:e}";
        divisor = 2.0;
        Console.WriteLine("{0}Divide two double-precision" 
            + " floating-point values:", nl);
        doubleResult = System.Math.IEEERemainder(System.Double.MaxValue, divisor);
        Console.Write("1) ");
        Console.WriteLine(str1, 
            ((System.Double)System.Double.MaxValue).ToString("e"),
            ((System.Double)divisor).ToString("f"),
            ((System.Double)doubleResult).ToString("e"));

        divisor = 3.0;
        doubleResult = System.Math.IEEERemainder(System.Double.MaxValue, divisor);
        Console.Write("2) ");
        Console.WriteLine(str1,
            ((System.Double)System.Double.MaxValue).ToString("e"), 
            ((System.Double)divisor).ToString("f"),
            ((System.Double)doubleResult).ToString("e"));
        Console.WriteLine("Note that two positive numbers can" 
            + " yield a negative remainder.");
    } //main
} //Sample

/*
This example produces the following results:

Calculate the quotient and remainder of two Int32 values:
2147483647/2 = 1073741823, with a remainder of 1.

Calculate the quotient and remainder of two Int64 values:
9223372036854775807/4 = 2305843009213693951, with a remainder of 3.

Divide two double-precision floating-point values:
1) The IEEE remainder of 1.797693e+308/2.00 is 0.000000e+000
2) The IEEE remainder of 1.797693e+308/3.00 is -1.000000e+000
Note that two positive numbers can yield a negative remainder.
*/

Plattformen

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

.NET Compact Framework

Unterstützt in: 2.0, 1.0

Siehe auch

Referenz

Math-Klasse
Math-Member
System-Namespace