5 // Miguel de Icaza (miguel@ximian.com)
7 // (C) Ximian, Inc. http://www.ximian.com
10 using System.Globalization;
14 public struct Single : IComparable, IFormattable { //, IConvertible {
15 public const float Epsilon = 1.4e-45f;
16 public const float MaxValue = 3.40282346638528859e38f;
17 public const float MinValue = -3.40282346638528859e38f;
18 public const float NaN = 0.0f / 0.0f;
19 public const float PositiveInfinity = 1.0f / 0.0f;
20 public const float NegativeInfinity = -1.0f / 0.0f;
22 // VES needs to know about value. public is workaround
23 // so source will compile
26 public int CompareTo (object v)
31 if (!(v is System.Single))
32 throw new ArgumentException (Locale.GetText ("Value is not a System.Single"));
34 return (int) (value - ((float) v));
37 public override bool Equals (object o)
39 if (!(o is System.Single))
42 return ((float) o) == value;
45 public override int GetHashCode ()
50 public static bool IsInfinity (float f)
52 return (f == PositiveInfinity || f == NegativeInfinity);
55 public static bool IsNaN (float f)
60 public static bool IsNegativeInfinity (float f)
62 return (f < 0.0f && (f == NegativeInfinity || f == PositiveInfinity));
65 public static bool IsPositiveInfinity (float f)
67 return (f > 0.0f && (f == NegativeInfinity || f == PositiveInfinity));
70 public static float Parse (string s)
72 return Parse (s, (NumberStyles.Float | NumberStyles.AllowThousands), null);
75 public static float Parse (string s, IFormatProvider fp)
77 return Parse (s, (NumberStyles.Float | NumberStyles.AllowThousands), fp);
80 public static float Parse (string s, NumberStyles style)
82 return Parse (s, style, null);
86 public static float Parse (string s, NumberStyles style, IFormatProvider fp)
89 throw new NotImplementedException ();
92 public override string ToString ()
94 return ToString(null, null);
97 public string ToString (IFormatProvider fp)
99 return ToString(null, fp);
102 public string ToString (string format)
104 return ToString(format, null);
108 public string ToString (string format, IFormatProvider fp)
110 // TODO: Implement me.
111 throw new NotImplementedException ();
114 // ============= IConvertible Methods ============ //
116 public TypeCode GetTypeCode ()
118 return TypeCode.Single;