alternative rng
This commit is contained in:
parent
80f6c741d2
commit
b8c7e44846
|
|
@ -13,6 +13,9 @@ uint16_t listofPrimes[L];
|
|||
// Random n-bits Zahl generieren. MSB ist immer 1
|
||||
uint16_t createRandomNumber(uint8_t bits) {
|
||||
|
||||
// äquivalent zu:
|
||||
// return rand() % pow(2,bits-1) + pow(2,bits-1);
|
||||
|
||||
uint16_t result = 1;
|
||||
for (uint8_t i = 0; i < bits - 1; i++) {
|
||||
result <<= 1;
|
||||
|
|
@ -64,7 +67,7 @@ int main() {
|
|||
findPrimesBiggerThan(listofPrimes, L, pow(2, k));
|
||||
|
||||
// Alice sucht ein i zw. 1 und L aus
|
||||
int iAlice = rand() % L - 1 + 1;
|
||||
int iAlice = rand() % (L - 1) + 1;
|
||||
|
||||
// Counter für false positives
|
||||
int falseCounter = 0;
|
||||
|
|
@ -84,5 +87,6 @@ int main() {
|
|||
}
|
||||
|
||||
// false-positive rate in Prozent. Empirisch: ca. 1%
|
||||
std::cout << 100 * (float)(falseCounter) / iterations << std::endl;
|
||||
std::cout << "False positivity rate: "
|
||||
<< 100 * (float)(falseCounter) / iterations << "%" << std::endl;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue