2004-05-18 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Tue, 18 May 2004 19:36:51 +0000 (19:36 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Tue, 18 May 2004 19:36:51 +0000 (19:36 -0000)
* SqlDecimal.cs : Fixed operator/ not to return positive always.
  Halfly fixed ConvertToPrecScale() that was broken.

svn path=/trunk/mcs/; revision=27624

mcs/class/System.Data/System.Data.SqlTypes/ChangeLog
mcs/class/System.Data/System.Data.SqlTypes/SqlDecimal.cs

index adf1011d1dd6390014c463810bab183e7dc18db4..99dcd9e25f04fcfaffcb361ebe6104452e705aa8 100644 (file)
@@ -1,3 +1,8 @@
+2004-05-18  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * SqlDecimal.cs : Fixed operator/ not to return positive always.
+         Halfly fixed ConvertToPrecScale() that was broken.
+
 2004-05-18  Atsushi Enomoto  <atsushi@ximian.com>
 
        * SqlDecimal.cs :
index 29e5dd46f764f604a4010796719b7725ace25776..7ed66f1a7487344b23414cee247493b07e67aaa1 100644 (file)
@@ -264,7 +264,9 @@ namespace System.Data.SqlTypes
 
                public static SqlDecimal ConvertToPrecScale (SqlDecimal n, int precision, int scale)
                {
-                       return new SqlDecimal ((byte)precision, (byte)scale, n.IsPositive, n.Data);
+//                     return new SqlDecimal ((byte)precision, (byte)scale, n.IsPositive, n.Data);
+                       // FIXME: precision
+                       return AdjustScale (n, scale - n.scale, true);
                }
 
                public static SqlDecimal Divide (SqlDecimal x, SqlDecimal y)
@@ -542,6 +544,7 @@ namespace System.Data.SqlTypes
                        int texp = 0;
                        int rc = 0;
                        byte prec = 0; // precision
+                       bool positive = ! (x.positive ^ y.positive);
 
                        prec = x.Precision >= y.Precision ? x.Precision : y.Precision;
                        DecimalDivSub (ref x, ref y, ref lo, ref hi, ref texp);
@@ -574,7 +577,7 @@ namespace System.Data.SqlTypes
                        int resultMi2 = (int)(hi);
                        int resultHi = (int)(hi >> 32);
 
-                       return new SqlDecimal (prec, (byte)sc, true, resultLo,
+                       return new SqlDecimal (prec, (byte)sc, positive, resultLo,
                                                       resultMi, resultMi2,
                                                       resultHi);
                }