2001-11-14 Miguel de Icaza <miguel@ximian.com>
[mono.git] / mcs / class / corlib / System / Double.cs
1 //
2 // System.Double.cs
3 //
4 // Author:
5 //   Miguel de Icaza (miguel@ximian.com)
6 //
7 // (C) Ximian, Inc.  http://www.ximian.com
8 //
9
10 using System.Globalization;
11
12 namespace System {
13         
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;
21                 
22                 // VES needs to know about value.  public is workaround
23                 // so source will compile
24                 public double value;
25
26                 public int CompareTo (object v)
27                 {
28                         if (v == null || !(v is System.Double))
29                                 throw new ArgumentException ("Value is not a System.Double");
30
31                         return (int) (value - ((double) v));
32                 }
33
34                 public override bool Equals (object o)
35                 {
36                         if (!(o is System.Double))
37                                 return false;
38
39                         return ((double) o) == value;
40                 }
41
42                 public override int GetHashCode ()
43                 {
44                         return (int) value;
45                 }
46
47                 public static bool IsInfinity (double d)
48                 {
49                         return (d == PositiveInfinity || d == NegativeInfinity);
50                 }
51
52                 public static bool IsNaN (double d)
53                 {
54                         return (d != d);
55                 }
56
57                 public static bool IsNegativeInfinity (double d)
58                 {
59                         return (d < 0.0d && (d == NegativeInfinity || d == PositiveInfinity));
60                 }
61
62                 public static bool IsPositiveInfinity (double d)
63                 {
64                         return (d > 0.0d && (d == NegativeInfinity || d == PositiveInfinity));
65                 }
66
67                 public static double Parse (string s)
68                 {
69                         return Parse (s, (NumberStyles.Float | NumberStyles.AllowThousands), null);
70                 }
71
72                 public static double Parse (string s, IFormatProvider fp)
73                 {
74                         return Parse (s, (NumberStyles.Float | NumberStyles.AllowThousands), fp);
75                 }
76
77                 public static double Parse (string s, NumberStyles style) 
78                 {
79                         return Parse (s, style, null);
80                 }
81
82                 public static double Parse (string s, NumberStyles style, IFormatProvider fp)
83                 {
84                         // TODO: Implement me
85                         return 0;
86                 }
87
88                 public override string ToString ()
89                 {
90                         return ToString (null, null);
91                 }
92
93                 public string ToString (IFormatProvider fp)
94                 {
95                         return ToString (null, fp);
96                 }
97
98                 public string ToString (string format)
99                 {
100                         return ToString (format, null);
101                 }
102
103                 public string ToString (string format, IFormatProvider fp)
104                 {
105                         // TODO: Implement me.
106                         return "";
107                 }
108
109                 // =========== IConvertible Methods =========== //
110
111                 public TypeCode GetTypeCode ()
112                 {
113                         return TypeCode.Double;
114                 }
115         }
116 }