Browse Source

2003-05-28 Ville Palo <[email protected]>

	* SqlInt16.cs: more checked fixes.
	* SqlInt64.cs: checked fixes.
	* SqlSingle.cs: checked fixes.

svn path=/trunk/mcs/; revision=14963
Ville Palo 22 years ago
parent
commit
91a2b57741

+ 6 - 0
mcs/class/System.Data/System.Data.SqlTypes/ChangeLog

@@ -1,3 +1,9 @@
+2003-05-28  Ville Palo <[email protected]>
+
+	* SqlInt16.cs: more checked fixes.
+	* SqlInt64.cs: checked fixes.
+	* SqlSingle.cs: checked fixes.
+	
 2003-05-28  Ville Palo <[email protected]>
 
 	* SqlInt16.cs: little fixes.

+ 4 - 6
mcs/class/System.Data/System.Data.SqlTypes/SqlInt16.cs

@@ -354,12 +354,10 @@ namespace System.Data.SqlTypes
 
 		public static explicit operator SqlInt16 (SqlDouble x)
 		{
-			//			checked {
-				if (x.IsNull)
-					return Null;
-				else 
-					return new SqlInt16 (checked ((short)x.Value));
-				//}
+			if (x.IsNull)
+				return Null;
+			else 
+				return new SqlInt16 (checked ((short)x.Value));
 		}
 
 		public static explicit operator short (SqlInt16 x)

+ 6 - 5
mcs/class/System.Data/System.Data.SqlTypes/SqlInt64.cs

@@ -381,12 +381,13 @@ namespace System.Data.SqlTypes
 
 		public static explicit operator SqlInt64 (SqlSingle x)
 		{
-			//checked {
-				if (x.IsNull) 
-					return SqlInt64.Null;
-				else
+			if (x.IsNull) 
+				return SqlInt64.Null;
+			else {
+				checked {
 					return new SqlInt64 ((long)x.Value);
-				//}
+				}
+			}
 		}
 
 		public static explicit operator SqlInt64 (SqlString x)

+ 26 - 11
mcs/class/System.Data/System.Data.SqlTypes/SqlSingle.cs

@@ -201,16 +201,25 @@ namespace System.Data.SqlTypes
 
 		public static SqlSingle operator + (SqlSingle x, SqlSingle y)
 		{
-			checked {
-				return new SqlSingle ((float)(x.Value + y.Value));
-			}
+			float f = (float)(x.Value + y.Value);
+
+			if (Single.IsInfinity (f))
+				throw new OverflowException ();
+
+			return new SqlSingle (f);
 		}
 
 		public static SqlSingle operator / (SqlSingle x, SqlSingle y)
 		{
-			checked {
-				return new SqlSingle (x.Value / y.Value);
+			float f = (float)(x.Value / y.Value);
+
+			if (Single.IsInfinity (f)) {
+				
+				if (y.Value == 0d) 
+					throw new DivideByZeroException ();
 			}
+
+			return new SqlSingle (x.Value / y.Value);
 		}
 
 		public static SqlBoolean operator == (SqlSingle x, SqlSingle y)
@@ -251,16 +260,22 @@ namespace System.Data.SqlTypes
 
 		public static SqlSingle operator * (SqlSingle x, SqlSingle y)
 		{
-			checked {
-				return new SqlSingle (x.Value * y.Value);
-			}
+			float f = (float)(x.Value * y.Value);
+			
+			if (Single.IsInfinity (f))
+				throw new OverflowException ();
+
+			return new SqlSingle (f);
 		}
 
 		public static SqlSingle operator - (SqlSingle x, SqlSingle y)
 		{
-			checked {
-				return new SqlSingle (x.Value - y.Value);
-			}
+			float f = (float)(x.Value - y.Value);
+
+			if (Single.IsInfinity (f))
+				throw new OverflowException ();
+
+			return new SqlSingle (f);
 		}
 
 		public static SqlSingle operator - (SqlSingle n)