diff options
author | David Goulet <dgoulet@ev0ke.net> | 2015-02-16 15:55:30 -0500 |
---|---|---|
committer | teor <teor2345@gmail.com> | 2015-05-06 18:05:16 +1000 |
commit | 8acccdbeac69b066be805f711133e188a7b04f28 (patch) | |
tree | 1d7e685781506b75946d6cdd1f4f61da2580deef /src/common/util.h | |
parent | dad5eb7e1f3c92974c7bcaaea325a05233a27494 (diff) | |
download | tor-8acccdbeac69b066be805f711133e188a7b04f28.tar.gz tor-8acccdbeac69b066be805f711133e188a7b04f28.zip |
Add an util function to cast double to int64_t
Use it in the sample_laplace_distribution function to make sure we return
the correct converted value after math operations are done on the input
values.
Thanks to Yawning for proposing a solution.
Signed-off-by: David Goulet <dgoulet@ev0ke.net>
Diffstat (limited to 'src/common/util.h')
-rw-r--r-- | src/common/util.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/common/util.h b/src/common/util.h index 30ac248b30..e303da2795 100644 --- a/src/common/util.h +++ b/src/common/util.h @@ -185,6 +185,7 @@ int64_t sample_laplace_distribution(double mu, double b, double p); int64_t add_laplace_noise(int64_t signal, double random, double delta_f, double epsilon); int n_bits_set_u8(uint8_t v); +int64_t cast_double_to_int64(double number); /* Compute the CEIL of <b>a</b> divided by <b>b</b>, for nonnegative <b>a</b> * and positive <b>b</b>. Works on integer types only. Not defined if a+b can |