Changeset 285 for Include/Classes/ActiveBasic/Math
- Timestamp:
- Jul 26, 2007, 5:43:54 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Include/Classes/ActiveBasic/Math/Math.ab
r276 r285 13 13 Function CopySign(x As Single, y As Single) As Single 14 14 SetDWord(VarPtr(CopySign), (GetDWord(VarPtr(x)) And &h7fffffff) Or (GetDWord(VarPtr(y)) And &h80000000)) 15 End Function 16 17 Function Hypot(x As Double, y As Double) As Double 18 If x = 0 Then 19 Hypot = Abs(y) 20 Else If y = 0 Then 21 Hypot = Abs(x) 22 Else 23 Dim ax = Abs(x) 24 Dim ay = Abs(y) 25 If ay > ax Then 26 Dim t = x / y 27 Hypot = ay * Sqr(1 + t * t) 28 Else 29 Dim t = y / x 30 Hypot = ax * Sqr(1 + t * t) 31 End If 32 End If 15 33 End Function 16 34 … … 39 57 40 58 Function IsInf(x As Double) As Boolean 41 Dim p As *DWord, nan As Double 42 p = VarPtr(x) As *DWord 59 Dim p = VarPtr(x) As *DWord 43 60 p[1] And= &h7fffffff 44 nan= ActiveBasic.Math.Detail.GetInf(False)45 IsInf = (memcmp(p As *Byte, VarPtr( nan), SizeOf (Double)) = 0)61 Dim inf = ActiveBasic.Math.Detail.GetInf(False) 62 IsInf = (memcmp(p As *Byte, VarPtr(inf), SizeOf (Double)) = 0) 46 63 End Function 47 64 48 65 Function IsFinite(x As Double) As Boolean 49 Dim p As *DWord, nan As Double 50 p = VarPtr(x) As *DWord 51 ' p[1] And= &h7ffe0000 66 Dim p = VarPtr(x) As *DWord 52 67 p[1] And= &H7FF00000 53 p[0] = 0 54 nan = ActiveBasic.Math.Detail.GetInf(/*x,*/ False) 55 IsFinite = (memcmp(p As BytePtr, VarPtr(nan), SizeOf (Double)) = 0) 68 IsFinite = p[1] And &H7FF00000 = &H7FF00000 56 69 End Function 57 70 … … 82 95 83 96 Function GetNaN() As Double 84 Dim p As *DWord 85 p = VarPtr(GetNaN) As *DWord 97 Dim p = VarPtr(GetNaN) As *DWord 86 98 p[0] = 0 87 99 p[1] = &H7FF80000 … … 104 116 While i >= 1 105 117 Dim t = (i * x) As Double 106 s = t / (2 + t / (2 * i + 1 + s))118 s = t * (2 * i + 1 + s) / (2 + t) 107 119 i-- 108 120 Wend … … 111 123 112 124 Function _Support_tan(x As Double, ByRef k As Long) As Double 113 Dim i As Long114 Dim t As Double, x2 As Double115 116 125 If x>=0 Then 117 126 k=Fix(x/(_System_PI/2)+0.5) … … 122 131 x=(x-(CDbl(3217)/CDbl(2048))*k)+4.4544551033807686783083602485579e-6*k 123 132 124 x2=x*x125 t=0133 Dim x2 = x * x 134 Dim t = 0 As Double 126 135 136 Dim i As Long 127 137 For i=19 To 3 Step -2 128 138 t=x2/(i-t)
Note:
See TracChangeset
for help on using the changeset viewer.