Index: trunk/ab5.0/ablib/src/com/decimal.ab
===================================================================
--- trunk/ab5.0/ablib/src/com/decimal.ab	(revision 506)
+++ trunk/ab5.0/ablib/src/com/decimal.ab	(revision 709)
@@ -8,5 +8,7 @@
 
 Class Decimal
+	Implements System.ICloneable, System.IEquatable<Decimal>', System.IComparable<Decimal>
 Public
+
 	Sub Decimal()
 	End Sub
@@ -22,5 +24,5 @@
 	Sub Decimal(lo As Long, mid As Long, hi As Long, isNegative As Boolean, scale As Byte)
 		If scale > 28 Then
-			Throw New ArgumentOutOfRangeException("scale")
+			Throw New System.ArgumentOutOfRangeException("scale - Decimal constructor")
 		End If
 		Dim sign As Byte
@@ -36,27 +38,27 @@
 
 	Sub Decimal(x As Long)
-		VarDecFromI4(x, dec)
+		Windows.ThrowIfFailed(VarDecFromI4(x, dec))
 	End Sub
 
 	Sub Decimal(x As DWord)
-		VarDecFromUI4(x, dec)
+		Windows.ThrowIfFailed(VarDecFromUI4(x, dec))
 	End Sub
 
 	Sub Decimal(x As Int64)
-		VarDecFromI8(x, dec)
+		Windows.ThrowIfFailed(VarDecFromI8(x, dec))
 	End Sub
 
 	Sub Decimal(x As QWord)
-		VarDecFromUI8(x, dec)
+		Windows.ThrowIfFailed(VarDecFromUI8(x, dec))
 	End Sub
 
 	Sub Decimal(x As Single)
-		VarDecFromR4(x, dec)
+		Windows.ThrowIfFailed(VarDecFromR4(x, dec))
 	End Sub
 
 	Sub Decimal(x As Double)
-		VarDecFromR8(x, dec)
-	End Sub
-/*
+		Windows.ThrowIfFailed(VarDecFromR8(x, dec))
+	End Sub
+
 	Const Function Operator() As Variant
 		Return New Variant(This)
@@ -197,12 +199,12 @@
 	End Function
 */
-/*
+
 	Const Function Operator +() As Decimal
 		Return New Decimal(dec)
 	End Function
-*/
+
 	Const Function Operator -() As Decimal
 		Dim ret = New Decimal
-		VarDecNeg(This.dec, ret.dec)
+		Windows.ThrowIfFailed(VarDecNeg(This.dec, ret.dec))
 		Return ret
 	End Function
@@ -210,5 +212,5 @@
 	Const Function Operator *(y As Decimal) As Decimal
 		Dim ret = New Decimal
-		VarDecMul(This.dec, y.dec, ret.dec)
+		Windows.ThrowIfFailed(VarDecMul(This.dec, y.dec, ret.dec))
 		Return ret
 	End Function
@@ -216,5 +218,5 @@
 	Const Function Operator /(y As Decimal) As Decimal
 		Dim ret = New Decimal
-		VarDecDiv(This.dec, y.dec, ret.dec)
+		Windows.ThrowIfFailed(VarDecDiv(This.dec, y.dec, ret.dec))
 		Return ret
 	End Function
@@ -222,5 +224,5 @@
 	Const Function Operator +(y As Decimal) As Decimal
 		Dim ret = New Decimal
-		VarDecAdd(This.dec, y.dec, ret.dec)
+		Windows.ThrowIfFailed(VarDecAdd(This.dec, y.dec, ret.dec))
 		Return ret
 	End Function
@@ -228,12 +230,14 @@
 	Const Function Operator -(y As Decimal) As Decimal
 		Dim ret = New Decimal
-		VarDecSub(This.dec, y.dec, ret.dec)
-		Return ret
-	End Function
-
+		Windows.ThrowIfFailed(VarDecSub(This.dec, y.dec, ret.dec))
+		Return ret
+	End Function
+
+	' ThrowIfFailedしていないことに注意
 	Static Function Compare(x As Decimal, y As Decimal) As HRESULT
-		Return VarDecCmp(x.dec, y.dec)
-	End Function
-
+		Compare = VarDecCmp(x.dec, y.dec)
+	End Function
+
+	' ThrowIfFailedしていないことに注意
 	Static Function Compare(x As Decimal, y As Double) As HRESULT
 		Return VarDecCmpR8(x.dec, y)
@@ -314,20 +318,20 @@
 	Const Function Abs() As Decimal
 		Abs = New Decimal
-		VarDecAbs(This.dec, Abs.dec)
+		Windows.ThrowIfFailed(VarDecAbs(This.dec, Abs.dec))
 	End Function
 
 	Const Function Fix() As Decimal
 		Fix = New Decimal
-		VarDecFix(This.dec, Fix.dec)
+		Windows.ThrowIfFailed(VarDecFix(This.dec, Fix.dec))
 	End Function
 
 	Const Function Int() As Decimal
 		Int = New Decimal
-		VarDecInt(This.dec, Int.dec)
+		Windows.ThrowIfFailed(VarDecInt(This.dec, Int.dec))
 	End Function
 
 	Const Function Round(c = 0 As Long) As Decimal
 		Round = New Decimal
-		VarDecRound(This.dec, c, Round.dec)
+		Windows.ThrowIfFailed(VarDecRound(This.dec, c, Round.dec))
 	End Function
 
@@ -336,19 +340,19 @@
 	End Function
 
-	Sub Dec(ByRef d As DECIMAL)
-		dec = d
-	End Sub
-
 	Const Function ToVariant() As Variant
 		Return New Variant(This)
 	End Function
 
+	Function ToBString() As BString
+		ToBString = New BString
+		Dim bs As BSTR
+		VarBstrFromDec(dec, LOCALE_USER_DEFAULT, LOCALE_USE_NLS, bs)
+		ToBString.Attach(bs)
+	End Function
+
 	Override Function ToString() As String
-		/*Using*/ Dim bstr = New BString
-			Dim bs As BSTR
-			VarBstrFromDec(dec, LOCALE_USER_DEFAULT, LOCALE_USE_NLS, bs)
-			bstr.Attach(bs)
+		Using bstr = ToBString()
 			ToString = bstr.ToString
-		bstr.Dispose() 'End Using
+		End Using
 	End Function
 
@@ -362,4 +366,15 @@
 		Return c = VARCMP_EQ
 	End Function
+
+	Override Function Equals(y As Object) As Boolean
+		If This.GetType().Equals(y.GetType()) Then
+			Equals = Equals(y As Decimal)
+		End If
+	End Function
+
+	Function Clone() As Decimal
+		Clone = New Decimal(This)
+	End Function
+
 Private
 	dec As DECIMAL
