2 // System.Data.SqlTypes.SqlDecimal
5 // Tim Coleman <tim@timcoleman.com>
7 // (C) Copyright 2002 Tim Coleman
12 namespace System.Data.SqlTypes
14 public struct SqlDecimal : INullable, IComparable
17 private decimal value;
19 public static readonly byte MaxPrecision = 38;
22 public static readonly byte MaxScale; // ????
24 public static readonly SqlDecimal MaxValue = new SqlDecimal (79228162514264337593543950335.0);
25 public static readonly SqlDecimal MinValue = new SqlDecimal (-79228162514264337593543950335.0);
26 public static readonly SqlDecimal Null;
32 public SqlDecimal (decimal value)
37 public SqlDecimal (double value)
39 this.value = ((decimal)value);
42 public SqlDecimal (int value)
44 this.value = ((decimal)value);
47 public SqlDecimal (long value)
49 this.value = ((decimal)value);
53 public SqlDecimal (byte bPrecision, byte bScale, bool fPositive, int[] bits)
55 throw new NotImplementedException();
59 public SqlDecimal (byte bPrecision, byte bScale, bool fPositive, int data1, int data2, int data3, int data4)
61 throw new NotImplementedException();
69 public byte[] BinData {
70 get { throw new NotImplementedException (); }
75 get { throw new NotImplementedException (); }
79 get { return (bool) (this == Null); }
82 public bool IsPositive {
83 get { return (this.Value > 0); }
87 public byte Precision {
88 get { throw new NotImplementedException (); }
93 get { throw new NotImplementedException (); }
96 public decimal Value {
99 throw new SqlNullValueException ("The property contains Null.");
110 public static SqlDecimal Abs (SqlDecimal n)
112 throw new NotImplementedException();
115 public static SqlDecimal Add (SqlDecimal x, SqlDecimal y)
121 public static SqlDecimal AdjustScale (SqlDecimal n, int digits, bool fRound)
123 throw new NotImplementedException ();
127 public static SqlDecimal Ceiling (SqlDecimal n)
129 throw new NotImplementedException();
133 public int CompareTo (object value)
135 throw new NotImplementedException ();
139 public static SqlDecimal ConvertToPrecScale (SqlDecimal n, int precision, int scale)
141 throw new NotImplementedException ();
144 public static SqlDecimal Divide (SqlDecimal x, SqlDecimal y)
150 public override bool Equals (object value)
152 throw new NotImplementedException ();
155 public static SqlBoolean Equals (SqlDecimal x, SqlDecimal y)
161 public static SqlDecimal Floor (SqlDecimal n)
163 throw new NotImplementedException();
167 public override int GetHashCode ()
172 public static SqlBoolean GreaterThan (SqlDecimal x, SqlDecimal y)
177 public static SqlBoolean GreaterThanOrEqual (SqlDecimal x, SqlDecimal y)
182 public static SqlBoolean LessThan (SqlDecimal x, SqlDecimal y)
187 public static SqlBoolean LessThanOrEqual (SqlDecimal x, SqlDecimal y)
192 public static SqlDecimal Multiply (SqlDecimal x, SqlDecimal y)
197 public static SqlBoolean NotEquals (SqlDecimal x, SqlDecimal y)
203 public static SqlDecimal Parse (string s)
205 throw new NotImplementedException ();
209 public static SqlDecimal Power (SqlDecimal n, double exp)
211 throw new NotImplementedException ();
215 public static SqlDecimal Round (SqlDecimal n, int position)
217 throw new NotImplementedException ();
221 public static SqlInt32 Sign (SqlDecimal n)
223 throw new NotImplementedException ();
226 public static SqlDecimal Subtract (SqlDecimal x, SqlDecimal y)
231 public double ToDouble ()
233 return ((double)value);
236 public SqlBoolean ToSqlBoolean ()
238 return ((SqlBoolean)this);
241 public SqlByte ToSqlByte ()
243 return ((SqlByte)this);
246 public SqlDouble ToSqlDouble ()
248 return ((SqlDouble)this);
251 public SqlInt16 ToSqlInt16 ()
253 return ((SqlInt16)this);
256 public SqlInt32 ToSqlInt32 ()
258 return ((SqlInt32)this);
261 public SqlInt64 ToSqlInt64 ()
263 return ((SqlInt64)this);
266 public SqlMoney ToSqlMoney ()
268 return ((SqlMoney)this);
271 public SqlSingle ToSqlSingle ()
273 return ((SqlSingle)this);
277 public SqlString ToSqlString ()
279 throw new NotImplementedException ();
283 public override string ToString ()
285 throw new NotImplementedException ();
289 public static SqlDecimal Truncate (SqlDecimal n, int position)
291 throw new NotImplementedException ();
294 public static SqlDecimal operator + (SqlDecimal x, SqlDecimal y)
296 return new SqlDecimal (x.Value + y.Value);
299 public static SqlDecimal operator / (SqlDecimal x, SqlDecimal y)
301 return new SqlDecimal (x.Value / y.Value);
304 public static SqlBoolean operator == (SqlDecimal x, SqlDecimal y)
306 if (x.IsNull || y.IsNull)
307 return SqlBoolean.Null;
309 return new SqlBoolean (x.Value == y.Value);
312 public static SqlBoolean operator > (SqlDecimal x, SqlDecimal y)
314 if (x.IsNull || y.IsNull)
315 return SqlBoolean.Null;
317 return new SqlBoolean (x.Value > y.Value);
320 public static SqlBoolean operator >= (SqlDecimal x, SqlDecimal y)
322 if (x.IsNull || y.IsNull)
323 return SqlBoolean.Null;
325 return new SqlBoolean (x.Value >= y.Value);
328 public static SqlBoolean operator != (SqlDecimal x, SqlDecimal y)
330 if (x.IsNull || y.IsNull)
331 return SqlBoolean.Null;
333 return new SqlBoolean (!(x.Value == y.Value));
336 public static SqlBoolean operator < (SqlDecimal x, SqlDecimal y)
338 if (x.IsNull || y.IsNull)
339 return SqlBoolean.Null;
341 return new SqlBoolean (x.Value < y.Value);
344 public static SqlBoolean operator <= (SqlDecimal x, SqlDecimal y)
346 if (x.IsNull || y.IsNull)
347 return SqlBoolean.Null;
349 return new SqlBoolean (x.Value <= y.Value);
352 public static SqlDecimal operator * (SqlDecimal x, SqlDecimal y)
354 return new SqlDecimal (x.Value * y.Value);
357 public static SqlDecimal operator - (SqlDecimal x, SqlDecimal y)
359 return new SqlDecimal (x.Value - y.Value);
362 public static SqlDecimal operator - (SqlDecimal n)
364 return new SqlDecimal (-(n.Value));
367 public static explicit operator SqlDecimal (SqlBoolean x)
372 return new SqlDecimal ((decimal)x.ByteValue);
375 public static explicit operator Decimal (SqlDecimal n)
380 public static explicit operator SqlDecimal (SqlDouble x)
385 return new SqlDecimal ((decimal)x.Value);
388 public static explicit operator SqlDecimal (SqlSingle x)
393 return new SqlDecimal ((decimal)x.Value);
397 public static explicit operator SqlDecimal (SqlString x)
399 throw new NotImplementedException ();
402 public static implicit operator SqlDecimal (decimal x)
404 return new SqlDecimal (x);
407 public static implicit operator SqlDecimal (SqlByte x)
412 return new SqlDecimal ((decimal)x.Value);
415 public static implicit operator SqlDecimal (SqlInt16 x)
420 return new SqlDecimal ((decimal)x.Value);
423 public static implicit operator SqlDecimal (SqlInt32 x)
428 return new SqlDecimal ((decimal)x.Value);
431 public static implicit operator SqlDecimal (SqlInt64 x)
436 return new SqlDecimal ((decimal)x.Value);
439 public static implicit operator SqlDecimal (SqlMoney x)
444 return new SqlDecimal ((decimal)x.Value);