/* ------------------------------------------- */
/* RndTest.c */
#include <windows.h>
static long x=327680;

__declspec(dllexport) float CALLBACK Rnd2(float f)
{
    unsigned u=*(unsigned*)&f;
    if (u&2146828287) {
        if (f<0) x=(u>>24)+u;
        x=x*16598013+12820163&16777215;
    }
    return x*(1.0/16777216.0);
}

__declspec(dllexport) void CALLBACK SRnd1(double d)
{
    unsigned short*s=(unsigned short*)&d;
    x=((s[2]^s[3])<<8)|(x&255);
}

__declspec(dllexport) void CALLBACK SRnd2(float f)
{
    unsigned char*c=(unsigned char*)&f;
    x=((c[0]^c[2])<<8)|((c[1]^c[3])<<16)|(x&255);
}

int WINAPI DllMain(HINSTANCE a,DWORD b,PVOID c) { return TRUE; }
/* ------------------------------------------- */


' ---------------------------------------------
' 標準モジュール
Declare Function Rnd2! Lib "RndTest" (Optional ByVal a! = 1)
Declare Sub SRnd1 Lib "RndTest" (ByVal a#)
Declare Sub SRnd2 Lib "RndTest" (ByVal a!)
Sub Randomize2(Optional ByVal a)
    If IsMissing(a) Then SRnd2 (Timer()) Else SRnd1 (a)
End Sub
' ---------------------------------------------