diff options
Diffstat (limited to 'src/libutil/util.c')
-rw-r--r-- | src/libutil/util.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/libutil/util.c b/src/libutil/util.c index 3fc1c98bf..36ca0cffc 100644 --- a/src/libutil/util.c +++ b/src/libutil/util.c @@ -2320,15 +2320,13 @@ rspamd_hash_seed (void) } static inline gdouble -rspamd_double_from_int64 (guint64 rnd_int) +rspamd_double_from_int64 (guint64 x) { - double res; - const double transform_bias = 2.2204460492503130808472633361816e-16; - - res = rnd_int >> 12; - res *= transform_bias; + const union { guint i; double d; } u = { + .i = G_GUINT64_CONSTANT(0x3FF) << 52 | x >> 12 + }; - return res; + return u.d - 1.0; } gdouble |