Sign in to follow this  
Sambori

[.net] NaN

Recommended Posts

using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { double a = 10; double b = 0; try { double c = a / b; } catch (ArithmeticException e) { Console.WriteLine("Exception {0}", e); } } } } This does not work. It cannot catch the exception. c is infinity instead of NaN.

Share this post


Link to post
Share on other sites
Have you checked the documentation? I have never programmed anything related to .NET, but found within a minute of searching.
Quote:

Dividing a floating-point value by zero will result in either positive infinity, negative infinity, or Not-a-Number (NaN) according to the rules of IEEE 754 arithmetic. Floating-point operations never throw an exception.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this