2 // System.Data.SqlTypes.SqlInt64
5 // Tim Coleman <tim@timcoleman.com>
7 // (C) Copyright 2002 Tim Coleman
11 using System.Globalization;
13 namespace System.Data.SqlTypes
15 public struct SqlInt64 : INullable, IComparable
23 public static readonly SqlInt64 MaxValue = new SqlInt64 (9223372036854775807);
24 public static readonly SqlInt64 MinValue = new SqlInt64 (-9223372036854775808);
26 public static readonly SqlInt64 Null;
27 public static readonly SqlInt64 Zero = new SqlInt64 (0);
33 public SqlInt64 (long value)
44 get { return !notNull; }
50 throw new SqlNullValueException ();
60 public static SqlInt64 Add (SqlInt64 x, SqlInt64 y)
65 public static SqlInt64 BitwiseAnd (SqlInt64 x, SqlInt64 y)
70 public static SqlInt64 BitwiseOr (SqlInt64 x, SqlInt64 y)
75 public int CompareTo (object value)
79 else if (!(value is SqlInt64))
80 throw new ArgumentException (Locale.GetText ("Value is not a System.Data.SqlTypes.SqlInt64"));
81 else if (((SqlInt64)value).IsNull)
84 return this.value.CompareTo (((SqlInt64)value).Value);
87 public static SqlInt64 Divide (SqlInt64 x, SqlInt64 y)
92 public override bool Equals (object value)
94 if (!(value is SqlInt64))
97 return (bool) (this == (SqlInt64)value);
100 public static SqlBoolean Equals (SqlInt64 x, SqlInt64 y)
105 public override int GetHashCode ()
107 return (int)(value & 0xffffffff) ^ (int)(value >> 32);
110 public static SqlBoolean GreaterThan (SqlInt64 x, SqlInt64 y)
115 public static SqlBoolean GreaterThanOrEqual (SqlInt64 x, SqlInt64 y)
120 public static SqlBoolean LessThan (SqlInt64 x, SqlInt64 y)
125 public static SqlBoolean LessThanOrEqual (SqlInt64 x, SqlInt64 y)
130 public static SqlInt64 Mod (SqlInt64 x, SqlInt64 y)
135 public static SqlInt64 Multiply (SqlInt64 x, SqlInt64 y)
140 public static SqlBoolean NotEquals (SqlInt64 x, SqlInt64 y)
145 public static SqlInt64 OnesComplement (SqlInt64 x)
154 public static SqlInt64 Parse (string s)
157 return new SqlInt64 (Int64.Parse (s));
161 public static SqlInt64 Subtract (SqlInt64 x, SqlInt64 y)
166 public SqlBoolean ToSqlBoolean ()
168 return ((SqlBoolean)this);
171 public SqlByte ToSqlByte ()
173 return ((SqlByte)this);
176 public SqlDecimal ToSqlDecimal ()
178 return ((SqlDecimal)this);
181 public SqlDouble ToSqlDouble ()
183 return ((SqlDouble)this);
186 public SqlInt16 ToSqlInt16 ()
188 return ((SqlInt16)this);
191 public SqlInt32 ToSqlInt32 ()
193 return ((SqlInt32)this);
196 public SqlMoney ToSqlMoney ()
198 return ((SqlMoney)this);
201 public SqlSingle ToSqlSingle ()
203 return ((SqlSingle)this);
206 public SqlString ToSqlString ()
208 return ((SqlString)this);
211 public override string ToString ()
216 return value.ToString ();
219 public static SqlInt64 Xor (SqlInt64 x, SqlInt64 y)
224 public static SqlInt64 operator + (SqlInt64 x, SqlInt64 y)
227 return new SqlInt64 (x.Value + y.Value);
231 public static SqlInt64 operator & (SqlInt64 x, SqlInt64 y)
233 return new SqlInt64 (x.value & y.Value);
236 public static SqlInt64 operator | (SqlInt64 x, SqlInt64 y)
238 return new SqlInt64 (x.value | y.Value);
241 public static SqlInt64 operator / (SqlInt64 x, SqlInt64 y)
243 return new SqlInt64 (x.Value / y.Value);
246 public static SqlBoolean operator == (SqlInt64 x, SqlInt64 y)
248 if (x.IsNull || y.IsNull)
249 return SqlBoolean.Null;
251 return new SqlBoolean (x.Value == y.Value);
254 public static SqlInt64 operator ^ (SqlInt64 x, SqlInt64 y)
256 return new SqlInt64 (x.Value ^ y.Value);
259 public static SqlBoolean operator > (SqlInt64 x, SqlInt64 y)
261 if (x.IsNull || y.IsNull)
262 return SqlBoolean.Null;
264 return new SqlBoolean (x.Value > y.Value);
267 public static SqlBoolean operator >= (SqlInt64 x, SqlInt64 y)
269 if (x.IsNull || y.IsNull)
270 return SqlBoolean.Null;
272 return new SqlBoolean (x.Value >= y.Value);
275 public static SqlBoolean operator != (SqlInt64 x, SqlInt64 y)
277 if (x.IsNull || y.IsNull)
278 return SqlBoolean.Null;
280 return new SqlBoolean (!(x.Value == y.Value));
283 public static SqlBoolean operator < (SqlInt64 x, SqlInt64 y)
285 if (x.IsNull || y.IsNull)
286 return SqlBoolean.Null;
288 return new SqlBoolean (x.Value < y.Value);
291 public static SqlBoolean operator <= (SqlInt64 x, SqlInt64 y)
293 if (x.IsNull || y.IsNull)
294 return SqlBoolean.Null;
296 return new SqlBoolean (x.Value <= y.Value);
299 public static SqlInt64 operator % (SqlInt64 x, SqlInt64 y)
301 return new SqlInt64(x.Value % y.Value);
304 public static SqlInt64 operator * (SqlInt64 x, SqlInt64 y)
307 return new SqlInt64 (x.Value * y.Value);
311 public static SqlInt64 operator ~ (SqlInt64 x)
313 return new SqlInt64 (~(x.Value));
316 public static SqlInt64 operator - (SqlInt64 x, SqlInt64 y)
319 return new SqlInt64 (x.Value - y.Value);
323 public static SqlInt64 operator - (SqlInt64 n)
325 return new SqlInt64 (-(n.Value));
328 public static explicit operator SqlInt64 (SqlBoolean x)
331 return SqlInt64.Null;
333 return new SqlInt64 ((long)x.ByteValue);
336 public static explicit operator SqlInt64 (SqlDecimal x)
339 return SqlInt64.Null;
341 return new SqlInt64 ((long)x.Value);
344 public static explicit operator SqlInt64 (SqlDouble x)
347 return SqlInt64.Null;
349 return new SqlInt64 ((long)x.Value);
352 public static explicit operator long (SqlInt64 x)
357 public static explicit operator SqlInt64 (SqlMoney x)
360 return SqlInt64.Null;
362 return new SqlInt64 ((long)x.Value);
365 public static explicit operator SqlInt64 (SqlSingle x)
368 return SqlInt64.Null;
370 return new SqlInt64 ((long)x.Value);
373 public static explicit operator SqlInt64 (SqlString x)
375 return SqlInt64.Parse (x.Value);
378 public static implicit operator SqlInt64 (long x)
380 return new SqlInt64 (x);
383 public static implicit operator SqlInt64 (SqlByte x)
386 return SqlInt64.Null;
388 return new SqlInt64 ((long)x.Value);
391 public static implicit operator SqlInt64 (SqlInt16 x)
394 return SqlInt64.Null;
396 return new SqlInt64 ((long)x.Value);
399 public static implicit operator SqlInt64 (SqlInt32 x)
402 return SqlInt64.Null;
404 return new SqlInt64 ((long)x.Value);