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)
25 if (v == null || !(v is System.UInt64))
26 throw new ArgumentException (Locale.GetText ("Value is not a System.UInt64"));
28 if (value == (ulong) v)
31 if (value < (ulong) v)
37 public override bool Equals (object o)
39 if (!(o is System.UInt64))
42 return ((ulong) o) == value;
45 public override int GetHashCode ()
47 return (int)(value & 0xffffffff) ^ (int)(value >> 32);
50 public static ulong Parse (string s)
52 return Parse (s, NumberStyles.Integer, null);
55 public static ulong Parse (string s, IFormatProvider fp)
57 return Parse (s, NumberStyles.Integer, fp);
60 public static ulong Parse (string s, NumberStyles style)
62 return Parse (s, style, null);
65 public static ulong Parse (string s, NumberStyles style, IFormatProvider fp)
68 throw new NotImplementedException ();
71 public override string ToString ()
73 return ToString ("G", null);
76 public string ToString (IFormatProvider fp)
78 return ToString ("G", fp);
81 public string ToString (string format)
83 return ToString (format, null);
86 public string ToString (string format, IFormatProvider fp)
91 fmt = (format == null) ? "G" : format;
94 nfi = NumberFormatInfo.CurrentInfo;
96 nfi = (NumberFormatInfo) fp.GetFormat (Type);
99 nfi = NumberFormatInfo.CurrentInfo;
102 return IntegerFormatter.NumberToString (fmt, nfi, value);
105 // =========== IConvertible Methods =========== //
107 public TypeCode GetTypeCode ()
109 return TypeCode.UInt64;