mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-19 19:10:17 +00:00
some fix
This commit is contained in:
parent
9d8207c6be
commit
e940ac3068
@ -109,9 +109,9 @@ struct mt19937{
|
||||
|
||||
/* generates a random number on [a, b]-interval */
|
||||
int64_t randint(int64_t a, int64_t b){
|
||||
uint32_t delta = b - a + 1;
|
||||
uint64_t delta = b - a + 1;
|
||||
if(delta < 0x80000000UL){
|
||||
return a + next_uint32() % delta;
|
||||
return a + next_uint32() % (uint32_t)delta;
|
||||
}else{
|
||||
return a + next_uint64() % delta;
|
||||
}
|
||||
|
@ -54,5 +54,16 @@ for i in range(len(seq)):
|
||||
actual_w = res.count(seq[i]) / k
|
||||
assert abs(actual_w - weights[i]) < max_error
|
||||
|
||||
# test seed
|
||||
from random import randint, seed
|
||||
seed(7)
|
||||
a = randint(1, 100)
|
||||
b = randint(-2**60, 1)
|
||||
c = randint(50, 100)
|
||||
|
||||
assert (a, b, c) == (16, -418020281577586157, 76)
|
||||
|
||||
seed(7)
|
||||
assert a == randint(1, 100)
|
||||
assert b == randint(-2**60, 1)
|
||||
assert c == randint(50, 100)
|
Loading…
x
Reference in New Issue
Block a user