From 37bcca6d99f4088e70e4247967e5f1320832447d Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 29 Feb 2016 16:15:28 +0100 Subject: strfry: non-uniform random number generation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/string/strfry.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/string/strfry.c b/src/string/strfry.c index 8463947..77a771f 100644 --- a/src/string/strfry.c +++ b/src/string/strfry.c @@ -43,7 +43,7 @@ char* strfry(char* anagram) for (i = strlen(anagram); --i;) { r = rand(); - j = (size_t)((double)r / ((double)RAND_MAX + 1) * (double)i); + j = (size_t)((double)r / ((double)RAND_MAX + 1) * (double)i); /* TODO This is not uniformally random. */ t = anagram[i], anagram[i] = anagram[j], anagram[j] = t; } return anagram; -- cgit v1.2.3-70-g09d2