Changeset 709 for trunk/ab5.0/ablib/src/com/decimal.ab
 Timestamp:
 Jun 29, 2009, 4:03:45 AM (15 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/ab5.0/ablib/src/com/decimal.ab
r478 r709 8 8 9 9 Class Decimal 10 Implements System.ICloneable, System.IEquatable<Decimal>', System.IComparable<Decimal> 10 11 Public 12 11 13 Sub Decimal() 12 14 End Sub … … 22 24 Sub Decimal(lo As Long, mid As Long, hi As Long, isNegative As Boolean, scale As Byte) 23 25 If scale > 28 Then 24 Throw New ArgumentOutOfRangeException("scale")26 Throw New System.ArgumentOutOfRangeException("scale  Decimal constructor") 25 27 End If 26 28 Dim sign As Byte … … 36 38 37 39 Sub Decimal(x As Long) 38 VarDecFromI4(x, dec)40 Windows.ThrowIfFailed(VarDecFromI4(x, dec)) 39 41 End Sub 40 42 41 43 Sub Decimal(x As DWord) 42 VarDecFromUI4(x, dec)44 Windows.ThrowIfFailed(VarDecFromUI4(x, dec)) 43 45 End Sub 44 46 45 47 Sub Decimal(x As Int64) 46 VarDecFromI8(x, dec)48 Windows.ThrowIfFailed(VarDecFromI8(x, dec)) 47 49 End Sub 48 50 49 51 Sub Decimal(x As QWord) 50 VarDecFromUI8(x, dec)52 Windows.ThrowIfFailed(VarDecFromUI8(x, dec)) 51 53 End Sub 52 54 53 55 Sub Decimal(x As Single) 54 VarDecFromR4(x, dec)56 Windows.ThrowIfFailed(VarDecFromR4(x, dec)) 55 57 End Sub 56 58 57 59 Sub Decimal(x As Double) 58 VarDecFromR8(x, dec)59 End Sub 60 /* 60 Windows.ThrowIfFailed(VarDecFromR8(x, dec)) 61 End Sub 62 61 63 Const Function Operator() As Variant 62 64 Return New Variant(This) … … 197 199 End Function 198 200 */ 199 /* 201 200 202 Const Function Operator +() As Decimal 201 203 Return New Decimal(dec) 202 204 End Function 203 */ 205 204 206 Const Function Operator () As Decimal 205 207 Dim ret = New Decimal 206 VarDecNeg(This.dec, ret.dec)208 Windows.ThrowIfFailed(VarDecNeg(This.dec, ret.dec)) 207 209 Return ret 208 210 End Function … … 210 212 Const Function Operator *(y As Decimal) As Decimal 211 213 Dim ret = New Decimal 212 VarDecMul(This.dec, y.dec, ret.dec)214 Windows.ThrowIfFailed(VarDecMul(This.dec, y.dec, ret.dec)) 213 215 Return ret 214 216 End Function … … 216 218 Const Function Operator /(y As Decimal) As Decimal 217 219 Dim ret = New Decimal 218 VarDecDiv(This.dec, y.dec, ret.dec)220 Windows.ThrowIfFailed(VarDecDiv(This.dec, y.dec, ret.dec)) 219 221 Return ret 220 222 End Function … … 222 224 Const Function Operator +(y As Decimal) As Decimal 223 225 Dim ret = New Decimal 224 VarDecAdd(This.dec, y.dec, ret.dec)226 Windows.ThrowIfFailed(VarDecAdd(This.dec, y.dec, ret.dec)) 225 227 Return ret 226 228 End Function … … 228 230 Const Function Operator (y As Decimal) As Decimal 229 231 Dim ret = New Decimal 230 VarDecSub(This.dec, y.dec, ret.dec) 231 Return ret 232 End Function 233 232 Windows.ThrowIfFailed(VarDecSub(This.dec, y.dec, ret.dec)) 233 Return ret 234 End Function 235 236 ' ThrowIfFailedしていないことに注意 234 237 Static Function Compare(x As Decimal, y As Decimal) As HRESULT 235 Return VarDecCmp(x.dec, y.dec) 236 End Function 237 238 Compare = VarDecCmp(x.dec, y.dec) 239 End Function 240 241 ' ThrowIfFailedしていないことに注意 238 242 Static Function Compare(x As Decimal, y As Double) As HRESULT 239 243 Return VarDecCmpR8(x.dec, y) … … 314 318 Const Function Abs() As Decimal 315 319 Abs = New Decimal 316 VarDecAbs(This.dec, Abs.dec)320 Windows.ThrowIfFailed(VarDecAbs(This.dec, Abs.dec)) 317 321 End Function 318 322 319 323 Const Function Fix() As Decimal 320 324 Fix = New Decimal 321 VarDecFix(This.dec, Fix.dec)325 Windows.ThrowIfFailed(VarDecFix(This.dec, Fix.dec)) 322 326 End Function 323 327 324 328 Const Function Int() As Decimal 325 329 Int = New Decimal 326 VarDecInt(This.dec, Int.dec)330 Windows.ThrowIfFailed(VarDecInt(This.dec, Int.dec)) 327 331 End Function 328 332 329 333 Const Function Round(c = 0 As Long) As Decimal 330 334 Round = New Decimal 331 VarDecRound(This.dec, c, Round.dec)335 Windows.ThrowIfFailed(VarDecRound(This.dec, c, Round.dec)) 332 336 End Function 333 337 … … 336 340 End Function 337 341 338 Sub Dec(ByRef d As DECIMAL)339 dec = d340 End Sub341 342 342 Const Function ToVariant() As Variant 343 343 Return New Variant(This) 344 344 End Function 345 345 346 Function ToBString() As BString 347 ToBString = New BString 348 Dim bs As BSTR 349 VarBstrFromDec(dec, LOCALE_USER_DEFAULT, LOCALE_USE_NLS, bs) 350 ToBString.Attach(bs) 351 End Function 352 346 353 Override Function ToString() As String 347 /*Using*/ Dim bstr = New BString 348 Dim bs As BSTR 349 VarBstrFromDec(dec, LOCALE_USER_DEFAULT, LOCALE_USE_NLS, bs) 350 bstr.Attach(bs) 354 Using bstr = ToBString() 351 355 ToString = bstr.ToString 352 bstr.Dispose() 'End Using356 End Using 353 357 End Function 354 358 … … 362 366 Return c = VARCMP_EQ 363 367 End Function 368 369 Override Function Equals(y As Object) As Boolean 370 If This.GetType().Equals(y.GetType()) Then 371 Equals = Equals(y As Decimal) 372 End If 373 End Function 374 375 Function Clone() As Decimal 376 Clone = New Decimal(This) 377 End Function 378 364 379 Private 365 380 dec As DECIMAL
Note:
See TracChangeset
for help on using the changeset viewer.