From d7309a5261018ab38fa8be8d5cfb2dbad267ac19 Mon Sep 17 00:00:00 2001 From: Neil Williams Date: Sun, 12 Feb 2006 18:55:36 +0000 Subject: [PATCH] Ensuring get_random_double returns at least some decimal places more often than not. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@13238 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/test-core/test-stuff.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/test-core/test-stuff.c b/src/test-core/test-stuff.c index fced685944..7d7639ab63 100644 --- a/src/test-core/test-stuff.c +++ b/src/test-core/test-stuff.c @@ -305,16 +305,13 @@ get_random_gint64(void) double get_random_double(void) { - union - { - double d; - gint64 i; - } ret; - + double d; + guint i; - ret.i = get_random_gint64(); - - return ret.d; + i = (guint)get_random_int_in_range(8,13); + /* using 0.9 and 7 increases chances of getting lots of decimals */ + d = ((double)get_random_int_in_range(8,999999) * i * 0.9 / 7); + return d; } const char*