Changeset 257


Ignore:
Timestamp:
May 19, 2007, 3:29:33 PM (17 years ago)
Author:
イグトランス (egtra)
Message:

VersionTest追加、Log1p追加

Files:
1 added
7 edited

Legend:

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

    r244 r257  
    232232            Dim tmp = x * _System_InverseSqrt2
    233233            Dim p = VarPtr(tmp) As *QWord
    234             Dim m = p[0] And &h7FF0000000000000
     234            Dim m = GetQWord(p) And &h7FF0000000000000
    235235            Dim k = ((m >> 52) As DWord) As Long - 1022
    236             p[0] = m + &h0010000000000000
     236            SetQWord(p, m + &h0010000000000000)
    237237            x /= tmp
    238 
    239             x--
    240             Dim s = 0 As Double
    241             Dim i = _System_Log_N As Long
    242             While i >= 1
    243                 Dim t = (i * x) As Double
    244                 s = t / (2 + t / (2 * i + 1 + s))
    245                 i--
    246             Wend
    247             Log = _System_LOG2 * k + x / (1 + s)
     238            Log = _System_LOG2 * k + _System_Log1p(x - 1)
    248239        End If
    249240    End Function
     
    602593    End Function
    603594Private
    604     Static Const _System_Log_N = 7 As Long
    605595    Static Const _System_Atan_N = 20 As Long
    606596    Static Const _System_UrTan_N = 17 As Long
  • Include/Classes/System/OperatingSystem.ab

    r237 r257  
    1010Public
    1111    ' Constractor
    12     Sub OperatingSystem(platform As PlatformID, version As Version)
     12    Sub OperatingSystem(platform As PlatformID, version As System.Version)
    1313        pf = platform
    1414        ver = version
     
    1818    Sub OperatingSystem(vi As OSVERSIONINFOA)
    1919        pf = vi.dwPlatformId As PlatformID
    20         ver = New Version(vi.dwMajorVersion, vi.dwMinorVersion, vi.dwBuildNumber)
     20        ver = New System.Version(vi.dwMajorVersion, vi.dwMinorVersion, vi.dwBuildNumber)
    2121        sp = New String(vi.szCSDVersion As PCSTR)
    2222    End Sub
     
    2424    Sub OperatingSystem(vi As OSVERSIONINFOW)
    2525        pf = vi.dwPlatformId As PlatformID
    26         ver = New Version(vi.dwMajorVersion, vi.dwMinorVersion, vi.dwBuildNumber)
     26        ver = New System.Version(vi.dwMajorVersion, vi.dwMinorVersion, vi.dwBuildNumber)
    2727        sp = New String(vi.szCSDVersion As PCSTR)
    2828    End Sub
     
    3333    End Function
    3434
    35     Const Function Version() As Version
     35    Const Function Version() As System.Version
    3636        Return ver
    3737    End Function
     
    7171Private
    7272    pf As PlatformID
    73     ver As Version
     73    ver As System.Version
    7474    sp As String
    7575End Class
  • Include/Classes/System/Runtime/InteropServices/GCHandle.ab

    r233 r257  
    1212    Sub Target(obj As Object)
    1313        allocated.Add(obj)
    14         handle = VarPtr(obj) 'ObjPtr
     14        handle = ObjPtr(obj)
    1515    End Sub
    1616
  • Include/Classes/System/Version.ab

    r233 r257  
    55
    66#require <api_winsock2.sbp>
     7
     8Namespace System
    79
    810Class Version
     
    149151End Class
    150152
     153End Namespace 'System
     154
    151155#endif '__SYSTEM_VERSION_AB__
  • Include/basic/function.sbp

    r251 r257  
    99Const _System_LOG2 = 0.6931471805599453094172321214581765680755
    1010Const _System_SQRT2 = 1.41421356237309504880168872421
     11Const _System_Log_N = 7 As Long
    1112
    1213
     
    2122        Exit Function
    2223    End If
    23     Dim pSrc As *QWord, pDest As *QWord
    24     pSrc = VarPtr(x) As *QWord
    25     pDest = VarPtr(ldexp) As *QWord
    26 
     24    Dim pSrc = VarPtr(x) As *QWord
     25    Dim pDest = VarPtr(ldexp) As *QWord
    2726    n += (pSrc[0] >> 52) As DWord And &h7FF
    28 
    2927    pDest[0] = n << 52 Or (pSrc[0] And &h800FFFFFFFFFFFFF)
    3028End Function
     
    3735    End If
    3836
    39     Dim pSrc As *QWord, pDest As *QWord
    40     pSrc = VarPtr(x) As *QWord
    41     pDest = VarPtr(frexp) As *QWord
     37    Dim pSrc = VarPtr(x) As *QWord
     38    Dim pDest = VarPtr(frexp) As *QWord
    4239    n = ((pSrc[0] >> 52) As DWord And &h7FF) - 1022
    4340    pDest[0] = (pSrc[0] And &h800FFFFFFFFFFFFF) Or &h3FE0000000000000
     
    10097End Function
    10198
    102 Function _System_GetInf(sign As BOOL) As Double
     99Function _System_GetInf(sign As Boolean) As Double
    103100    Dim s = 0 As QWord
    104101    If sign Then s = 1 << 63
     
    115112End Function
    116113
    117 Function _System_GetInf(sign As BOOL) As Double
     114Function _System_GetInf(sign As Boolean) As Double
    118115    Dim s = 0 As DWord
    119116    If sign Then s = (1 As DWord) << 31
     
    240237End Function
    241238
     239Function Log1p(x As Double) As Double
     240    If x < -1 Or IsNaN(x) Then
     241        Log1p = _System_GetNaN()
     242    ElseIf x = 0 Then
     243        x = 0
     244    ElseIf IsInf(x) Then
     245        Log1p = x
     246    Else
     247        Log1p = _System_Log1p(x)
     248    End If
     249End Function
     250
     251Function _System_Log1p(x As Double) As Double
     252    Dim s = 0 As Double
     253    Dim i = 7 As Long
     254    While i >= 1
     255        Dim t = (i * x) As Double
     256        s = t / (2 + t / (2 * i + 1 + s))
     257        i--
     258    Wend
     259    Return x / (1 + s)
     260End Function
     261
    242262Function Sgn(number As Double) As Long
    243263    Sgn = Math.Sign(number)
     
    293313    Dim p As *DWord
    294314    p = VarPtr(x) As *DWord
    295     IsNaN = FALSE
     315    IsNaN = False
    296316    If (p[1] And &H7FF00000) = &H7FF00000 Then
    297317        If (p[0] <> 0) Or ((p[1] And &HFFFFF) <> 0) Then
     
    299319        End If
    300320    End If
    301 
    302 '   IsNaN=FALSE
    303321End Function
    304322
     
    307325    p = VarPtr(x) As *DWord
    308326    p[1] And= &h7fffffff
    309     nan = _System_GetInf(FALSE)
     327    nan = _System_GetInf(False)
    310328    IsInf = (memcmp(p As *Byte, VarPtr(nan), SizeOf (Double)) = 0)
    311329End Function
     
    321339    p[1] And= &H7FF00000
    322340    p[0] = 0
    323     nan = _System_GetInf(/*x,*/ FALSE)
     341    nan = _System_GetInf(/*x,*/ False)
    324342    IsFinite = (memcmp(p As BytePtr, VarPtr(nan), SizeOf (Double)) = 0)
    325343End Function
  • TestCase/SimpleTestCase/SimpleTestCase.idx

    r254 r257  
    1010#include "GCHandleTest.ab"
    1111_ClearNamespaceImported
     12#include "VersionTest.ab"
     13_ClearNamespaceImported
    1214#include "PathTest.ab"
    1315_ClearNamespaceImported
  • TestCase/SimpleTestCase/SimpleTestCase.pj

    r254 r257  
    3030StringTest.ab
    3131GCHandleTest.ab
     32VersionTest.ab
    3233PathTest.ab
Note: See TracChangeset for help on using the changeset viewer.