GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing decimalbasic.web.fc2.com — Bit Array Huge Bit Array BASIC allocates a variable that takes only 0 or 1 to a regular variable. This is inefficient when we use a big-size array. REM Eratosthenes' sieve
DECLARE EXTERNAL FUNCTION GetArray, Test
DECLARE EXTERNAL SUB FreeArray, setbit
LET Nmax=10000
LET p=GetArray(Nmax)
IF p<>0 THEN
FOR i=2 TO Nmax-1
IF Test(p,i)=0 THEN
PRINT i
FOR j=i^2 TO Nmax-1 STEP i
CALL SetBit(p,j)
NEXT j
END IF
NEXT i
CALL FreeArray(p)
END IF
END
EXTERNAL FUNCTION GetArray(s)
! Gets (s+1) bit memories and clear them with zeros.
! The result is the address of the memory.
! If the result is 0, the function failed.
FUNCTION GetArray_sub(s)
ASSIGN "BitArray.DLL","GetArray"
END FUNCTION
IF 0<=s AND s<2^32 THEN
LET GetArray=getArray_sub(s)
ELSE
LET GetArray=0
END if
END FUNCTION
EXTERNAL SUB FreeArray(p)
! Returns the memory, where p is the value gotten by GetArray.
ASSIGN "BitArray.DLL","FreeArray"
END SUB
EXTERNAL FUNCTION Test(p,i)
! Gets the i-th bit, where p is the value gotten by GetArray.
ASSIGN "BitArray.DLL", "Test"
END FUNCTION
EXTERNAL SUB SetBit(p,i)
! Sets the i-th bit to 1, where p is the value gotten by GetArray.
ASSIGN "BitArray.DLL", "SetBit"
END SUB
EXTERNAL SUB ResetBit(p,i)
! Sets the i-th bit to 0, where p is the value gotten by GetArray.
ASSIGN "BitArray.DLL", "ResetBit"
END SUB
Back |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |