System.ArithmeticException Class

See Also: ArithmeticException Members

ArithmeticException is the base class for DivideByZeroException, NotFiniteNumberException, and OverflowException. In general, use one of the derived classes of ArithmeticException to more precisely indicate the exact nature of the error. Throw an ArithmeticException if you are only interested in capturing a general arithmetic error.

ArithmeticException uses the HRESULT COR_E_ARITHMETIC, which has the value 0x80070216.

For a list of initial property values for an instance of ArithmeticException, see the ArithmeticException constructors.

All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe.

The following example demonstrates an error that causes the system to throw a ArithmeticException error.

**C# Example**

using System; class testNan { public static void Main() { double myNan = Double.NaN; try { Math.Sign(myNan); } catch (ArithmeticException e) { Console.WriteLine("Error: {0}",e); } } }

The output is

at System.Math.Sign(Double value)

at testNan.Main()