mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
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
This commit is contained in:
@@ -305,16 +305,13 @@ get_random_gint64(void)
|
|||||||
double
|
double
|
||||||
get_random_double(void)
|
get_random_double(void)
|
||||||
{
|
{
|
||||||
union
|
double d;
|
||||||
{
|
guint i;
|
||||||
double d;
|
|
||||||
gint64 i;
|
|
||||||
} ret;
|
|
||||||
|
|
||||||
|
|
||||||
ret.i = get_random_gint64();
|
i = (guint)get_random_int_in_range(8,13);
|
||||||
|
/* using 0.9 and 7 increases chances of getting lots of decimals */
|
||||||
return ret.d;
|
d = ((double)get_random_int_in_range(8,999999) * i * 0.9 / 7);
|
||||||
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char*
|
const char*
|
||||||
|
|||||||
Reference in New Issue
Block a user