[Gnucash-changes] r13238 - gnucash/trunk/src/test-core - Ensuring
get_random_double returns at least some decimal places more
often than not.
Neil Williams
codehelp at cvs.gnucash.org
Sun Feb 12 13:55:36 EST 2006
Author: codehelp
Date: 2006-02-12 13:55:36 -0500 (Sun, 12 Feb 2006)
New Revision: 13238
Trac: http://svn.gnucash.org/trac/changeset/13238
Modified:
gnucash/trunk/src/test-core/test-stuff.c
Log:
Ensuring get_random_double returns at least some decimal places more often than not.
Modified: gnucash/trunk/src/test-core/test-stuff.c
===================================================================
--- gnucash/trunk/src/test-core/test-stuff.c 2006-02-12 18:31:30 UTC (rev 13237)
+++ gnucash/trunk/src/test-core/test-stuff.c 2006-02-12 18:55:36 UTC (rev 13238)
@@ -305,16 +305,13 @@
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*
More information about the gnucash-changes
mailing list