2 // System.Data.SqlTypes.SqlInt64
5 // Tim Coleman <tim@timcoleman.com>
7 // (C) Copyright 2002 Tim Coleman
12 namespace System.Data.SqlTypes
14 public struct SqlInt64 : INullable, IComparable
21 public static readonly SqlInt64 MaxValue; // 2^63 - 1
24 public static readonly SqlInt64 MinValue; // -2^63
26 public static readonly SqlInt64 Null;
27 public static readonly SqlInt64 Zero = new SqlInt64 (0);
33 public SqlInt64 (long value)
43 get { return (bool) (this == Null); }
49 throw new SqlNullValueException ();
59 public static SqlInt64 Add (SqlInt64 x, SqlInt64 y)
64 public static SqlInt64 BitwiseAnd (SqlInt64 x, SqlInt64 y)
69 public static SqlInt64 BitwiseOr (SqlInt64 x, SqlInt64 y)
74 public int CompareTo (object value)
78 else if (!(value is SqlInt64))
79 throw new ArgumentException (Locale.GetText ("Value is not a System.Data.SqlTypes.SqlInt64"));
80 else if (value.IsNull)
83 return value.CompareTo (value.Value);
86 public static SqlInt64 Divide (SqlInt64 x, SqlInt64 y)
91 public override bool Equals (object value)
93 if (!(value is SqlInt64))
96 return (bool) (this == value);
99 public static SqlBoolean Equals (SqlInt64 x, SqlInt64 y)
105 public override int GetHashCode ()
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)
151 public static SqlInt64 Parse (string s)
153 throw new NotImplementedException ();
156 public static SqlInt64 Subtract (SqlInt64 x, SqlInt64 y)
161 public SqlBoolean ToSqlBoolean ()
163 return ((SqlBoolean)this);
166 public SqlByte ToSqlByte ()
168 return ((SqlByte)this);
171 public SqlDecimal ToSqlDecimal ()
173 return ((SqlDecimal)this);
176 public SqlDouble ToSqlDouble ()
178 return ((SqlDouble)this);
181 public SqlInt16 ToSqlInt16 ()
183 return ((SqlInt16)this);
186 public SqlInt32 ToSqlInt32 ()
188 return ((SqlInt32)this);
191 public SqlMoney ToSqlMoney ()
193 return ((SqlMoney)this);
196 public SqlSingle ToSqlSingle ()
198 return ((SqlSingle)this);
201 public SqlString ToSqlString ()
203 return ((SqlString)this);
206 public override string ToString ()
208 return value.ToString ();
211 public static SqlInt64 Xor (SqlInt64 x, SqlInt64 y)
216 public static SqlInt64 operator + (SqlInt64 x, SqlInt64 y)
218 return new SqlInt64 (x.Value + y.Value);
221 public static SqlInt64 operator & (SqlInt64 x, SqlInt64 y)
223 return new SqlInt64 (x.value & y.Value);
226 public static SqlInt64 operator | (SqlInt64 x, SqlInt64 y)
228 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 SqlBoolean operator == (SqlInt64 x, SqlInt64 y)
238 if (x.IsNull || y.IsNull)
239 return SqlBoolean.Null;
241 return new SqlBoolean (x.Value == y.Value);
244 public static SqlInt64 operator ^ (SqlInt64 x, SqlInt64 y)
246 return new SqlInt64 (x.Value ^ y.Value);
249 public static SqlBoolean operator > (SqlInt64 x, SqlInt64 y)
251 if (x.IsNull || y.IsNull)
252 return SqlBoolean.Null;
254 return new SqlBoolean (x.Value > y.Value);
257 public static SqlBoolean operator >= (SqlInt64 x, SqlInt64 y)
259 if (x.IsNull || y.IsNull)
260 return SqlBoolean.Null;
262 return new SqlBoolean (x.Value >= y.Value);
265 public static SqlBoolean operator != (SqlInt64 x, SqlInt64 y)
267 if (x.IsNull || y.IsNull)
268 return SqlBoolean.Null;
270 return new SqlBoolean (!(x.Value == y.Value));
273 public static SqlBoolean operator < (SqlInt64 x, SqlInt64 y)
275 if (x.IsNull || y.IsNull)
276 return SqlBoolean.Null;
278 return new SqlBoolean (x.Value < y.Value);
281 public static SqlBoolean operator <= (SqlInt64 x, SqlInt64 y)
283 if (x.IsNull || y.IsNull)
284 return SqlBoolean.Null;
286 return new SqlBoolean (x.Value <= y.Value);
289 public static SqlInt64 operator % (SqlInt64 x, SqlInt64 y)
291 return new SqlInt64(x.Value % y.Value);
294 public static SqlInt64 operator * (SqlInt64 x, SqlInt64 y)
296 return new SqlInt64 (x.Value * y.Value);
299 public static SqlInt64 operator ~ (SqlInt64 x)
301 return new SqlInt64 (~(x.Value));
304 public static SqlInt64 operator - (SqlInt64 x, SqlInt64 y)
306 return new SqlInt64 (x.Value - y.Value);
309 public static SqlInt64 operator - (SqlInt64 n)
311 return new SqlInt64 (-(n.Value));
314 public static explicit operator SqlInt64 (SqlBoolean x)
317 return SqlInt64.Null;
319 return new SqlInt64 ((long)x.ByteValue);
322 public static explicit operator SqlInt64 (SqlDecimal x)
325 return SqlInt64.Null;
327 return new SqlInt64 ((long)x.Value);
330 public static explicit operator SqlInt64 (SqlDouble x)
333 return SqlInt64.Null;
335 return new SqlInt64 ((long)x.Value);
338 public static explicit operator long (SqlInt64 x)
343 public static explicit operator SqlInt64 (SqlMoney x)
346 return SqlInt64.Null;
348 return new SqlInt64 ((long)x.Value);
351 public static explicit operator SqlInt64 (SqlSingle x)
354 return SqlInt64.Null;
356 return new SqlInt64 ((long)x.Value);
360 public static explicit operator SqlInt64 (SqlString x)
362 throw new NotImplementedException ();
365 public static implicit operator SqlInt64 (long x)
367 return new SqlInt64 (x);
370 public static implicit operator SqlInt64 (SqlByte x)
373 return SqlInt64.Null;
375 return new SqlInt64 ((long)x.Value);
378 public static implicit operator SqlInt64 (SqlInt16 x)
381 return SqlInt64.Null;
383 return new SqlInt64 ((long)x.Value);
386 public static implicit operator SqlInt64 (SqlInt32 x)
389 return SqlInt64.Null;
391 return new SqlInt64 ((long)x.Value);