diff options
author | Atsushi Eno <atsushieno@gmail.com> | 2004-05-18 18:12:03 +0400 |
---|---|---|
committer | Atsushi Eno <atsushieno@gmail.com> | 2004-05-18 18:12:03 +0400 |
commit | d356c5ad9045120417baa63897139a0aa2bda72b (patch) | |
tree | c3b2a3df4617a74a76cb66a2ff5bd60925b83937 /mcs/class/System.Data/System.Data.SqlTypes | |
parent | f83b3edda4a5ef72b6cbd14f803aafdb223cf2d0 (diff) |
2004-05-18 Atsushi Enomoto <atsushi@ximian.com>
* SqlDecimal.cs : Fixed Truncate() to work fine.
* SqlMoney.cs : Added one hack line in operator/ to work fine.
svn path=/trunk/mcs/; revision=27589
Diffstat (limited to 'mcs/class/System.Data/System.Data.SqlTypes')
-rw-r--r-- | mcs/class/System.Data/System.Data.SqlTypes/ChangeLog | 5 | ||||
-rw-r--r-- | mcs/class/System.Data/System.Data.SqlTypes/SqlDecimal.cs | 15 | ||||
-rw-r--r-- | mcs/class/System.Data/System.Data.SqlTypes/SqlMoney.cs | 2 |
3 files changed, 18 insertions, 4 deletions
diff --git a/mcs/class/System.Data/System.Data.SqlTypes/ChangeLog b/mcs/class/System.Data/System.Data.SqlTypes/ChangeLog index f1b45e3325e..74290ba28ef 100644 --- a/mcs/class/System.Data/System.Data.SqlTypes/ChangeLog +++ b/mcs/class/System.Data/System.Data.SqlTypes/ChangeLog @@ -1,5 +1,10 @@ 2004-05-18 Atsushi Enomoto <atsushi@ximian.com> + * SqlDecimal.cs : Fixed Truncate() to work fine. + * SqlMoney.cs : Added one hack line in operator/ to work fine. + +2004-05-18 Atsushi Enomoto <atsushi@ximian.com> + * SqlDecimal.cs : Fixed AdjustScale(). When reducing digits, scale parameter was incorrect. diff --git a/mcs/class/System.Data/System.Data.SqlTypes/SqlDecimal.cs b/mcs/class/System.Data/System.Data.SqlTypes/SqlDecimal.cs index f50b98f5717..96f527ccaac 100644 --- a/mcs/class/System.Data/System.Data.SqlTypes/SqlDecimal.cs +++ b/mcs/class/System.Data/System.Data.SqlTypes/SqlDecimal.cs @@ -1012,10 +1012,17 @@ namespace System.Data.SqlTypes public static SqlDecimal Truncate (SqlDecimal n, int position) { - int prec = n.Precision;// + (position - n.Scale); - int sc = position; - return new SqlDecimal ((byte)prec, (byte)sc, - n.IsPositive, n.Data); + int diff = n.scale - position; + if (diff == 0) + return n; + int [] data = n.Data; + decimal d = new decimal (data [0], data [1], data [2], !n.positive, 0); + decimal x = 10; + for (int i = 0; i < diff; i++, x *= 10) + d = d - d % x; + data = Decimal.GetBits (d); + data [3] = 0; + return new SqlDecimal (n.precision, n.scale, n.positive, data); } public static SqlDecimal operator + (SqlDecimal x, SqlDecimal y) diff --git a/mcs/class/System.Data/System.Data.SqlTypes/SqlMoney.cs b/mcs/class/System.Data/System.Data.SqlTypes/SqlMoney.cs index 5888c6e054a..f198317e55b 100644 --- a/mcs/class/System.Data/System.Data.SqlTypes/SqlMoney.cs +++ b/mcs/class/System.Data/System.Data.SqlTypes/SqlMoney.cs @@ -259,6 +259,8 @@ namespace System.Data.SqlTypes public static SqlMoney operator / (SqlMoney x, SqlMoney y) { checked { + // FIXME: It's kinda mystery. should not be required. + decimal d = x.Value / y.Value; return new SqlMoney (x.Value / y.Value); } } |