5 // Miguel de Icaza (miguel@ximian.com)
7 // (C) Ximian, Inc. http://www.ximian.com
10 using System.Globalization;
14 public struct Double : IComparable, IFormattable { //, IConvertible {
15 public const double Epsilon = 4.9406564584124650e-324;
16 public const double MaxValue = 1.7976931348623157e308;
17 public const double MinValue = -1.7976931348623157e308;
18 public const double NaN = 0.0d / 0.0d;
19 public const double NegativeInfinity = -1.0d / 0.0d;
20 public const double PositiveInfinity = 1.0d / 0.0d;
22 // VES needs to know about value. public is workaround
23 // so source will compile
26 public int CompareTo (object v)
28 if (v == null || !(v is System.Double))
29 throw new ArgumentException ("Value is not a System.Double");
31 return (int) (value - ((double) v));
34 public override bool Equals (object o)
36 if (!(o is System.Double))
39 return ((double) o) == value;
42 public override int GetHashCode ()
47 public static bool IsInfinity (double d)
49 return (d == PositiveInfinity || d == NegativeInfinity);
52 public static bool IsNaN (double d)
57 public static bool IsNegativeInfinity (double d)
59 return (d < 0.0d && (d == NegativeInfinity || d == PositiveInfinity));
62 public static bool IsPositiveInfinity (double d)
64 return (d > 0.0d && (d == NegativeInfinity || d == PositiveInfinity));
67 public static double Parse (string s)
69 return Parse (s, (NumberStyles.Float | NumberStyles.AllowThousands), null);
72 public static double Parse (string s, IFormatProvider fp)
74 return Parse (s, (NumberStyles.Float | NumberStyles.AllowThousands), fp);
77 public static double Parse (string s, NumberStyles style)
79 return Parse (s, style, null);
82 public static double Parse (string s, NumberStyles style, IFormatProvider fp)
88 public override string ToString ()
90 return ToString (null, null);
93 public string ToString (IFormatProvider fp)
95 return ToString (null, fp);
98 public string ToString (string format)
100 return ToString (format, null);
103 public string ToString (string format, IFormatProvider fp)
105 // TODO: Implement me.
109 // =========== IConvertible Methods =========== //
111 public TypeCode GetTypeCode ()
113 return TypeCode.Double;