Ignore:
Timestamp:
Jun 2, 2007, 7:04:19 PM (17 years ago)
Author:
イグトランス (egtra)
Message:

StringのResizeを呼ぶコンストラクタでメモリ確保されない場合を排除、ほか微修正

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Include/Classes/System/Math.ab

    r257 r268  
    11' Classes/System/Math.ab
     2
     3#require <Classes/ActiveBasic/Math/Math.ab>
    24
    35#ifndef __SYSTEM_MATH_AB__
    46#define __SYSTEM_MATH_AB__
     7
     8Namespace System
    59
    610Class Math
     
    5660    Static Function Acos(x As Double) As Double
    5761        If x < -1 Or x > 1 Then
    58             Acos = _System_GetNaN()
     62            Acos = ActiveBasic.Math.Detail.GetNaN()
    5963        Else
    6064            Acos = _System_HalfPI - Asin(x)
     
    6468    Static Function Asin(x As Double) As Double
    6569        If x < -1 Or x > 1 Then
    66             Asin = _System_GetNaN()
     70            Asin = ActiveBasic.Math.Detail.GetNaN()
    6771        Else
    6872            Asin = Math.Atan(x / Sqrt(1 - x * x))
     
    7175
    7276    Static Function Atan(x As Double) As Double
    73         If IsNaN(x) Then
     77        If ActiveBasic.Math.IsNaN(x) Then
    7478            Atan = x
    7579            Exit Function
    76         ElseIf IsInf(x) Then
    77             Atan = CopySign(_System_PI, x)
     80        ElseIf ActiveBasic.Math.IsInf(x) Then
     81            Atan = ActiveBasic.Math.CopySign(_System_PI, x)
    7882            Exit Function
    7983        End If
     
    113117            Atan2 = Atn(y / x)
    114118            If x < 0 Then
    115                 Atan2 += CopySign(_System_PI, y)
     119                Atan2 += ActiveBasic.Math.CopySign(_System_PI, y)
    116120            End If
    117121        End If
     
    131135
    132136    Static Function Cos(x As Double) As Double
    133         If IsNaN(x) Then
     137        If ActiveBasic.Math.IsNaN(x) Then
    134138            Return x
    135         ElseIf IsInf(x) Then
    136             Return _System_GetNaN()
     139        ElseIf ActiveBasic.Math.IsInf(x) Then
     140            Return ActiveBasic.Math.Detail.GetNaN()
    137141        End If
    138142
     
    159163
    160164    Static Function Exp(x As Double) As Double
    161         If IsNaN(x) Then
     165        If ActiveBasic.Math.IsNaN(x) Then
    162166            Return x
    163         Else If IsInf(x) Then
     167        Else If ActiveBasic.Math.IsInf(x) Then
    164168            If 0 > x Then
    165169                Return 0
     
    200204
    201205    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()
    203207        Dim q = x / y
    204208        If q <> Int(q) Then
     
    224228    Static Function Log(x As Double) As Double
    225229        If x = 0 Then
    226             Log = _System_GetInf(True)
    227         ElseIf x < 0 Or IsNaN(x) Then
    228             Log = _System_GetNaN()
    229         ElseIf IsInf(x) Then
     230            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
    230234            Log = x
    231235        Else
     
    236240            SetQWord(p, m + &h0010000000000000)
    237241            x /= tmp
    238             Log = _System_LOG2 * k + _System_Log1p(x - 1)
     242            Log = _System_LOG2 * k + ActiveBasic.Math.Detail.Log1p(x - 1)
    239243        End If
    240244    End Function
     
    481485
    482486    Static Function Sin(value As Double) As Double
    483         If IsNaN(value) Then
     487        If ActiveBasic.Math.IsNaN(value) Then
    484488            Return value
    485         ElseIf IsInf(value) Then
    486             Return _System_GetNaN()
     489        ElseIf ActiveBasic.Math.IsInf(value) Then
     490            Return ActiveBasic.Math.Detail.GetNaN()
    487491            Exit Function
    488492        End If
     
    514518        Dim i As *Word, j As Long, jj As Long, k As Long
    515519        If x > 0 Then
    516             If IsInf(x) Then
     520            If ActiveBasic.Math.IsInf(x) Then
    517521                Sqrt = x
    518522            Else
     
    530534            End If
    531535        ElseIf x < 0 Then
    532             Sqrt = _System_GetNaN()
     536            Sqrt = ActiveBasic.Math.Detail.GetNaN()
    533537        Else
    534538            'x = 0 Or NaN
     
    538542
    539543    Static Function Tan(x As Double) As Double
    540         If IsNaN(x) Then
     544        If ActiveBasic.Math.IsNaN(x) Then
    541545            Tan = x
    542546            Exit Function
    543         ElseIf IsInf(x) Then
    544             Tan = _System_GetNaN()
     547        ElseIf ActiveBasic.Math.IsInf(x) Then
     548            Tan = ActiveBasic.Math.Detail.GetNaN()
    545549            Exit Function
    546550        End If
     
    554558            Return -1 / t
    555559        Else
    556             Return CopySign(_System_GetInf(FALSE), -t)
     560            Return ActiveBasic.Math.CopySign(ActiveBasic.Math.Detail.GetInf(False), -t)
    557561        End If
    558562    End Function
     
    599603End Class
    600604
     605End Namespace
     606
    601607Const _System_HalfPI = (_System_PI * 0.5)
    602608Const _System_InverseHalfPI = (2 / _System_PI) '1 / (PI / 2)
     
    604610Const _System_InverseSqrt2 = 0.70710678118654752440084436210485 '1 / (√2)
    605611
    606 
    607612#endif '__SYSTEM_MATH_AB__
Note: See TracChangeset for help on using the changeset viewer.