Jump to content
  • Advertisement
Sign in to follow this  
Sambori

[.net] NaN

This topic is 3045 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
I have not did any experiments, but math tells us that +1/0 = positive infinity, -1/0 = negative infinity, 0/0 is NaN. I guess the same applies here.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!