X-Git-Url: https://git.draconx.ca/gitweb/cdecl99.git/blobdiff_plain/1c3b0c0e6f9339e76e42f6393e554c7dfc58e205..306005996991bea30a81ccbe923f455b752bcbeb:/t/rng.c diff --git a/t/rng.c b/t/rng.c index 8ae2f13..fec991c 100644 --- a/t/rng.c +++ b/t/rng.c @@ -1,6 +1,6 @@ /* * Simple random number generator for testing. - * Copyright © 2022 Nick Bowler + * Copyright © 2022-2023 Nick Bowler * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,8 +27,6 @@ #include #include #include -#include -#include #include "test.h" @@ -116,20 +114,6 @@ void test_rng_free(struct test_rng *rng) free(rng); } -#define BITS_PER_FP_DIGIT ( FLT_RADIX < 4 ? 1 \ - : FLT_RADIX < 8 ? 2 \ - : FLT_RADIX < 16 ? 3 \ - : FLT_RADIX < 32 ? 4 \ - : 5 ) - -double test_rng_uniform(struct test_rng *rng) -{ - unsigned long long val = xoshiro256p(rng->state); - int prec = MIN(64, DBL_MANT_DIG*BITS_PER_FP_DIGIT); - - return ldexp(val >> (64-prec), -prec); -} - /* Calculate the least power of two greater than val, minus 1. */ static unsigned rng_mask(unsigned val) {