diff options
-rw-r--r-- | src/mpfr-mini-gmp.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/mpfr-mini-gmp.c b/src/mpfr-mini-gmp.c index f69e26969..abdcb9aa2 100644 --- a/src/mpfr-mini-gmp.c +++ b/src/mpfr-mini-gmp.c @@ -40,7 +40,9 @@ gmp_randinit_default (gmp_randstate_t state) void gmp_randseed_ui (gmp_randstate_t state, unsigned long int seed) { - srand48 (seed); + /* With a portable version of the conversion from unsigned long to long + (at least GCC and Clang optimize this expression to identity). */ + srand48 (seed > LONG_MAX ? -1 - (long) ~seed : (long) seed); } #endif |