# NaN and Infinity

Source: Internet
Author: User

`Using fasterflect;using system;using system.collections.generic;using system.linq;using System.Reflection;using  System.text;using System.threading.tasks;namespace consoleapplication2{class Program_nanandinfinity {static void Main (string[] args) {/* C # language, for the number of Int,long and decimal types, the result of any number divided by 0 is infinity, not int,long             and the decimal type, so an expression such as 6/0 can be evaluated as an error.            However, the double and float types actually have a special value that can represent infinity: 5.0/0.0 = Infinity (infinity), the only exception to this rule is 0.0/0.0 = NaN (not a number).            ///Indicates a value other than the number (Nan) Console.WriteLine ("Nan = = Nan: {0}", Double.NaN = = Double.NaN);            Console.WriteLine ("Nan! = Nan: {0}", Double.NaN! = Double.NaN);            Console.WriteLine ("Nan.equals (NaN): {0}", Double.NaN.Equals (Double.NaN)); Console.WriteLine ("! Nan.equals (NaN): {0} ",!            Double.NaN.Equals (Double.NaN));             Console.WriteLine ("IsNaN: {0}", Double.isnan (Double.NaN)); Console.WriteLine ("\nnan > NaN: {0}", DOuble.            NaN > Double.NaN);            Console.WriteLine ("Nan >= nan: {0}", Double.NaN >= Double.NaN);            Console.WriteLine ("Nan < nan: {0}", Double.NaN < Double.NaN);            Console.WriteLine ("NaN < 100.0: {0}", Double.NaN < 100.0);            Console.WriteLine ("NaN <= 100.0: {0}", Double.NaN <= 100.0);            Console.WriteLine ("NaN >= 100.0: {0}", Double.NaN > 100.0);            Console.WriteLine ("Nan.compareto (NaN): {0}", Double.NaN.CompareTo (Double.NaN));            Console.WriteLine ("Nan.compareto (100.0): {0}", Double.NaN.CompareTo (100.0)); Console.WriteLine ("(100.0)". CompareTo (Double.NaN): {0} ", (100.0).            CompareTo (Double.NaN)); Double. PositiveInfinity, float. PositiveInfinity the value of this constant is the result of a positive number being removed by 0.            This constant is returned when the result of the operation is greater than MaxValue.              Console.WriteLine ("5/2 = {0}", 5/2);      2 Console.WriteLine ("5.0/2.0 = {0}", 5.0/2.0); 2.5 Console.WriteLine ("5.0/2 = {0}", 5.0/2);          2.5 Console.WriteLine ("5/2.0 = {0}", 5/2.0);      2.5 Console.WriteLine ("5.0/0.0 = {0}", 5.0/0.0);          Infinity Console.WriteLine ("5.0/0 = {0}", 5.0/0);      Infinity Console.WriteLine ("0.0/0.0 = {0}", 0.0/0.0);          NaN Console.WriteLine ("5/0.0 = {0}", 5/0.0);          Infinity Console.WriteLine ("0.0/0 = {0}", 0.0/0); NaN Console.WriteLine ("Double. MinValue < Double. PositiveInfinity: {0} ", double. MinValue <= Double.            PositiveInfinity); Console.WriteLine ("Double. MinValue > Double. PositiveInfinity: {0} ", double. MinValue >= Double.            PositiveInfinity); Console.WriteLine ("Double. MaxValue < Double. PositiveInfinity: {0} ", double. MaxValue <= Double.            PositiveInfinity); Console.WriteLine ("Double. MaxValue > Double. PositiveInfinity: {0} ", double. MaxValue >= Double. PositiveinfiniTY); Double. NegativeInfinity, float. NegativeInfinity the value of this constant is the result of negative numbers being removed by 0.            This constant is returned when the result of the operation is less than MinValue.            Console.WriteLine (" -5/2 = {0}", -5/2);    2 Console.WriteLine (" -5.0/2.0 = {0}", -5.0/2.0);        -2.5 Console.WriteLine (" -5.0/2 = {0}", -5.0/2);        -2.5 Console.WriteLine (" -5/2.0 = {0}", -5/2.0);    -2.5 Console.WriteLine (" -5.0/0.0 = {0}", -5.0/0.0);        Infinity Console.WriteLine (" -5.0/0 = {0}", -5.0/0);      Infinity Console.WriteLine ("0.0/0.0 = {0}", 0.0/0.0);        NaN Console.WriteLine (" -5/0.0 = {0}", -5/0.0);          Infinity Console.WriteLine ("0.0/0 = {0}", 0.0/0); NaN Console.WriteLine ("Double. MinValue < Double. NegativeInfinity: {0} ", double. MinValue <= Double.            NegativeInfinity); Console.WriteLine ("Double. MinValue > Double. NegativeInfinity:{0} ", double. MinValue >= Double.            NegativeInfinity); Console.WriteLine ("Double. MaxValue < Double. NegativeInfinity: {0} ", double. MaxValue <= Double.            NegativeInfinity); Console.WriteLine ("Double. MaxValue > Double. NegativeInfinity: {0} ", double. MaxValue >= Double.            NegativeInfinity); Determines whether the Infinity Console.WriteLine ("Float"). Isinfinity (0.5F) = {0} ", float.                                         Isinfinity (0.5F)); False Console.WriteLine ("Float. Isinfinity (float. negativeinfinity) = {0} ", float. Isinfinity (float.     NegativeInfinity)); True Console.WriteLine ("Float. Isinfinity (float. PositiveInfinity) = {0} ", float. Isinfinity (float.     PositiveInfinity)); True//To determine if Nan or infinity can only use double. IsNaN () and float. Isinfinity ()///reference: Https://msdn.microsoft.com/zh-cn/library/system.double.nan (v=vs.110). aspx Cons Ole.        Read (); }    }}`

NaN and Infinity

Related Keywords:

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.