Changeset 268 for Include/Classes/System/Math.ab
- Timestamp:
- Jun 2, 2007, 7:04:19 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Include/Classes/System/Math.ab
r257 r268 1 1 ' Classes/System/Math.ab 2 3 #require <Classes/ActiveBasic/Math/Math.ab> 2 4 3 5 #ifndef __SYSTEM_MATH_AB__ 4 6 #define __SYSTEM_MATH_AB__ 7 8 Namespace System 5 9 6 10 Class Math … … 56 60 Static Function Acos(x As Double) As Double 57 61 If x < -1 Or x > 1 Then 58 Acos = _System_GetNaN()62 Acos = ActiveBasic.Math.Detail.GetNaN() 59 63 Else 60 64 Acos = _System_HalfPI - Asin(x) … … 64 68 Static Function Asin(x As Double) As Double 65 69 If x < -1 Or x > 1 Then 66 Asin = _System_GetNaN()70 Asin = ActiveBasic.Math.Detail.GetNaN() 67 71 Else 68 72 Asin = Math.Atan(x / Sqrt(1 - x * x)) … … 71 75 72 76 Static Function Atan(x As Double) As Double 73 If IsNaN(x) Then77 If ActiveBasic.Math.IsNaN(x) Then 74 78 Atan = x 75 79 Exit Function 76 ElseIf IsInf(x) Then77 Atan = CopySign(_System_PI, x)80 ElseIf ActiveBasic.Math.IsInf(x) Then 81 Atan = ActiveBasic.Math.CopySign(_System_PI, x) 78 82 Exit Function 79 83 End If … … 113 117 Atan2 = Atn(y / x) 114 118 If x < 0 Then 115 Atan2 += CopySign(_System_PI, y)119 Atan2 += ActiveBasic.Math.CopySign(_System_PI, y) 116 120 End If 117 121 End If … … 131 135 132 136 Static Function Cos(x As Double) As Double 133 If IsNaN(x) Then137 If ActiveBasic.Math.IsNaN(x) Then 134 138 Return x 135 ElseIf IsInf(x) Then136 Return _System_GetNaN()139 ElseIf ActiveBasic.Math.IsInf(x) Then 140 Return ActiveBasic.Math.Detail.GetNaN() 137 141 End If 138 142 … … 159 163 160 164 Static Function Exp(x As Double) As Double 161 If IsNaN(x) Then165 If ActiveBasic.Math.IsNaN(x) Then 162 166 Return x 163 Else If IsInf(x) Then167 Else If ActiveBasic.Math.IsInf(x) Then 164 168 If 0 > x Then 165 169 Return 0 … … 200 204 201 205 Static Function IEEERemainder(x As Double, y As Double) As Double 202 If y = 0 Then Return _System_GetNaN()206 If y = 0 Then Return ActiveBasic.Math.Detail.GetNaN() 203 207 Dim q = x / y 204 208 If q <> Int(q) Then … … 224 228 Static Function Log(x As Double) As Double 225 229 If x = 0 Then 226 Log = _System_GetInf(True)227 ElseIf x < 0 Or IsNaN(x) Then228 Log = _System_GetNaN()229 ElseIf IsInf(x) Then230 Log = ActiveBasic.Math.Detail.GetInf(True) 231 ElseIf x < 0 Or ActiveBasic.Math.IsNaN(x) Then 232 Log = ActiveBasic.Math.Detail.GetNaN() 233 ElseIf ActiveBasic.Math.IsInf(x) Then 230 234 Log = x 231 235 Else … … 236 240 SetQWord(p, m + &h0010000000000000) 237 241 x /= tmp 238 Log = _System_LOG2 * k + _System_Log1p(x - 1)242 Log = _System_LOG2 * k + ActiveBasic.Math.Detail.Log1p(x - 1) 239 243 End If 240 244 End Function … … 481 485 482 486 Static Function Sin(value As Double) As Double 483 If IsNaN(value) Then487 If ActiveBasic.Math.IsNaN(value) Then 484 488 Return value 485 ElseIf IsInf(value) Then486 Return _System_GetNaN()489 ElseIf ActiveBasic.Math.IsInf(value) Then 490 Return ActiveBasic.Math.Detail.GetNaN() 487 491 Exit Function 488 492 End If … … 514 518 Dim i As *Word, j As Long, jj As Long, k As Long 515 519 If x > 0 Then 516 If IsInf(x) Then520 If ActiveBasic.Math.IsInf(x) Then 517 521 Sqrt = x 518 522 Else … … 530 534 End If 531 535 ElseIf x < 0 Then 532 Sqrt = _System_GetNaN()536 Sqrt = ActiveBasic.Math.Detail.GetNaN() 533 537 Else 534 538 'x = 0 Or NaN … … 538 542 539 543 Static Function Tan(x As Double) As Double 540 If IsNaN(x) Then544 If ActiveBasic.Math.IsNaN(x) Then 541 545 Tan = x 542 546 Exit Function 543 ElseIf IsInf(x) Then544 Tan = _System_GetNaN()547 ElseIf ActiveBasic.Math.IsInf(x) Then 548 Tan = ActiveBasic.Math.Detail.GetNaN() 545 549 Exit Function 546 550 End If … … 554 558 Return -1 / t 555 559 Else 556 Return CopySign(_System_GetInf(FALSE), -t)560 Return ActiveBasic.Math.CopySign(ActiveBasic.Math.Detail.GetInf(False), -t) 557 561 End If 558 562 End Function … … 599 603 End Class 600 604 605 End Namespace 606 601 607 Const _System_HalfPI = (_System_PI * 0.5) 602 608 Const _System_InverseHalfPI = (2 / _System_PI) '1 / (PI / 2) … … 604 610 Const _System_InverseSqrt2 = 0.70710678118654752440084436210485 '1 / (√2) 605 611 606 607 612 #endif '__SYSTEM_MATH_AB__
Note:
See TracChangeset
for help on using the changeset viewer.