C# BigInteger Division

Description

BigInteger Division Divides a specified BigInteger value by another specified BigInteger value by using integer division.

Syntax

BigInteger.Division has the following syntax.


public static BigInteger operator /(
  BigInteger dividend,
  BigInteger divisor
)

Parameters

BigInteger.Division has the following parameters.

  • dividend - The value to be divided.
  • divisor - The value to divide by.

Returns

BigInteger.Division method returns The integral result of the division.

Example


using System;//  ww  w . ja  v  a  2 s  .c  o  m
using System.Numerics;

public class Example
{
   public static void Main()
   {
      BigInteger divisor = BigInteger.Pow(Int64.MaxValue, 2);

      BigInteger[] dividends = { BigInteger.Multiply((BigInteger) Single.MaxValue, 2), 
                                 BigInteger.Multiply(Int32.MaxValue, Int64.MaxValue),
                                 divisor + BigInteger.One };

      foreach (BigInteger dividend in dividends)
      {
         BigInteger quotient;
         BigInteger remainder = 0;
         Console.WriteLine("   Using Divide method:     {0:N0}", 
                           BigInteger.Divide(dividend, divisor));

      }            
   }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Numerics »




BigInteger
Complex