it's about a Gimmick actually with no practical use at all:
I am curious about a large bit array datatype or work-around for this.
IIRC we once had this topic already (the search function had - again - no hits) - and the former answer was "no, not possible".
Nevertheless, the challenge is about a mathematical algorithm to find prime numbers and has been started by a member of our German Mindstorms forum;
the following approach is called "Sieve of Eratosthenes".
This algorithm needs a large array to sort out all multiples of already detected primes, but the poor memory of the NXT lets one only calculate primes up to about 32200 when using arrays of char:
Code: Select all
// Primzahlen mit Sieb des Eratosthenes
#define test 32200
#define clock() ( CurrentTick()-FirstTick() )
char list[test];
task main() {
unsigned int i, j, hits=0;
ClearScreen();
SetSleepTimeout(0);
TextOut(0,56,"Primzahlen bis:");
for(i=2;i<test;i++) {
if(list[i]!=1) {
NumOut(0, 48,i);
++hits;
for(j=i*i;j<test;j+=i) {
list[j]=1;
}
}
}
TextOut(0,36,"fertig! gefunden:");
NumOut (0,30, hits);
TextOut(0,16,"Laufzeit (ms):");
NumOut (0, 8, clock());
while(1);
}
I personally doubted that because it once already had been negated - but maybe one or the other member meanwhile found a way?
For this algorithm above every single bit in this list (or array) must be accessable (read/write) by indices and counting through indices.
If it should be possible (of course, within a reasonable time and performance), then the range of tested primes might be enlarged from about 32,000 to maybe 8 million or so ....
As I already wrote, it's only a gimmick and it is really not of great importance but I am curious anyway.