diff --git a/common/pseudorand.c b/common/pseudorand.c index 817a9e5bf..c7bff3df6 100644 --- a/common/pseudorand.c +++ b/common/pseudorand.c @@ -44,6 +44,13 @@ uint64_t pseudorand_u64(void) return isaac64_next_uint64(&isaac64); } +double pseudorand_double(void) +{ + init_if_needed(); + + return isaac64_next_double(&isaac64); +} + const struct siphash_seed *siphash_seed(void) { init_if_needed(); diff --git a/common/pseudorand.h b/common/pseudorand.h index 0a46223bf..65272adda 100644 --- a/common/pseudorand.h +++ b/common/pseudorand.h @@ -13,6 +13,12 @@ uint64_t pseudorand(uint64_t max); */ uint64_t pseudorand_u64(void); +/** + * pseudorand - pseudo (guessable!) random number between 0 (inclusive) and 1 + * (exclusive). + */ +double pseudorand_double(void); + /** * Get the siphash seed for hash tables. */