Decimal.Divide() Method in C# Last Updated : 11 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report This method is used to divide the two specified decimal values. Syntax: public static decimal Divide (decimal a1, decimal a2); Parameters: a1: This parameter specifies the dividend. a2: This parameter specifies the divisor. Return Value: The result of dividing a1 by a2. Exceptions: DivideByZeroException: This occurs when a2 is zero. OverflowException: If the result of dividing a1 and a2 is less than smallest possible value of Decimal or greater than the largest possible value of Decimal. Below programs illustrate the use of Decimal.Divide(Decimal, Decimal) Method: Example 1: csharp // C# program to demonstrate the // Decimal.Divide(Decimal, // Decimal) Method using System; class GFG { // Main Method public static void Main() { try { // Declaring the decimal variables Decimal a1 = 4.02m; Decimal a2 = 2.01m; // dividing the two Decimal value // using Divide() method; Decimal value = Decimal.Divide(a1, a2); // Display the division Console.WriteLine("Result of "+ "division : {0}", value); } catch (OverflowException e) { Console.Write("Exception Thrown: "); Console.Write("{0}", e.GetType(), e.Message); } } } Output: Result of division : 2 Example 2: Program for OverflowException csharp // C# program to demonstrate the // Decimal.Divide(Decimal, // Decimal) Method using System; class GFG { // Main Method public static void Main() { try { // Declaring the decimal variables Decimal a1 = Decimal.MaxValue; Decimal a2 = 0.01m; // dividing the two Decimal value // using Divide() method; Decimal value = Decimal.Divide(a1, a2); // Display the division Console.WriteLine("Result of "+ "division : {0}", value); } catch (OverflowException e) { Console.Write("Exception Thrown: "); Console.Write("{0}", e.GetType(), e.Message); } } } Output: Exception Thrown: System.OverflowException Example 3: Program for DivideByZeroException csharp // C# program to demonstrate the // Decimal.Divide(Decimal, // Decimal) Method using System; class GFG { // Main Method public static void Main() { try { // Declaring the decimal variables Decimal a1 = 4.02m; Decimal a2 = 0.00m; // dividing the two Decimal value // using Divide() method; Decimal value = Decimal.Divide(a1, a2); // Display the division Console.WriteLine("Result of"+ " division : {0}", value); } catch (DivideByZeroException e) { Console.Write("Exception Thrown: "); Console.Write("{0}", e.GetType(), e.Message); } } } Output: Exception Thrown: System.DivideByZeroException Reference: https://learn.microsoft.com/en-us/dotnet/api/system.decimal.divide?view=netframework-4.7.2 Comment More infoAdvertise with us Next Article Decimal.Truncate() Method in C# I IshwarGupta Follow Improve Article Tags : C# CSharp-method CSharp-Decimal-Struct Similar Reads Decimal.Floor() Method in C# This method is used to round the decimal to the closest integer toward negative infinity. Syntax: public static decimal Floor (decimal d); Parameter: d: This parameter specifies the decimal which will be rounded off. Return Value: If d has a fractional part, the next whole Decimal number toward nega 2 min read Decimal.Multiply() Method in C# This method is used to multiply two specified decimal values. Syntax: public static decimal Multiply (decimal a1, decimal a2);Parameters: a1: This parameter specifies the multiplicand. a2: This parameter specifies the multiplier.Return Value: The result of the multiplication of a1 & a2. Exceptio 2 min read Decimal.Subtract() Method in C# This method is used to subtract the one specified Decimal value from another. Syntax: public static decimal Subtract (decimal a1, decimal a2); Parameters: a1: This parameter specifies the minuend. a2: This parameter specifies the subtrahend. Return Value: Result of subtracting a2 from a1. Exceptions 2 min read Decimal.Truncate() Method in C# This method is used to get the integral digits of the specified Decimal by discarding any fractional digits. This method rounds the specified value to the nearest whole number by removing the digits after the decimal point. Syntax: public static decimal Truncate (decimal d); Here, d is the decimal n 1 min read C# | Math.DivRem() Method In C#, Math.DivRem() is a Math class method which divides two numbers and returns the remainder. By using Division operator, we do not get the remainder in a separate variable but using DivRem() method, we get both. This method can be overloaded by passing different type and number of arguments to i 3 min read C# | Math.IEEERemainder() Method In C#, IEEERemainder() is a Math class method which is used to return the remainder resulting from the division of a specified number by another specified number. Syntax: public static double IEEERemainder (double a, double b); Parameters: a: It is the dividend of type System.Double.b: It is the div 2 min read Like