5 // Miguel de Icaza (miguel@ximian.com)
7 // (C) Ximian, Inc. http://www.ximian.com
10 using System.Globalization;
15 public struct UInt64 : IComparable, IFormattable { //, IConvertible {
16 private static Type Type = typeof (ulong);
18 public const ulong MaxValue = 0xffffffffffffffff;
19 public const ulong MinValue = 0;
23 public int CompareTo (object v)
28 if (!(v is System.UInt64))
29 throw new ArgumentException (Locale.GetText ("Value is not a System.UInt64"));
31 if (value == (ulong) v)
34 if (value < (ulong) v)
40 public override bool Equals (object o)
42 if (!(o is System.UInt64))
45 return ((ulong) o) == value;
48 public override int GetHashCode ()
50 return (int)(value & 0xffffffff) ^ (int)(value >> 32);
53 public static ulong Parse (string s)
55 return Parse (s, NumberStyles.Integer, null);
58 public static ulong Parse (string s, IFormatProvider fp)
60 return Parse (s, NumberStyles.Integer, fp);
63 public static ulong Parse (string s, NumberStyles style)
65 return Parse (s, style, null);
68 public static ulong Parse (string s, NumberStyles style, IFormatProvider fp)
71 throw new NotImplementedException ();
74 public override string ToString ()
76 return ToString ("G", null);
79 public string ToString (IFormatProvider fp)
81 return ToString ("G", fp);
84 public string ToString (string format)
86 return ToString (format, null);
89 public string ToString (string format, IFormatProvider fp)
94 fmt = (format == null) ? "G" : format;
97 nfi = NumberFormatInfo.CurrentInfo;
99 nfi = (NumberFormatInfo) fp.GetFormat (Type);
102 nfi = NumberFormatInfo.CurrentInfo;
105 return IntegerFormatter.NumberToString (fmt, nfi, value);
108 // =========== IConvertible Methods =========== //
110 public TypeCode GetTypeCode ()
112 return TypeCode.UInt64;