summaryrefslogtreecommitdiff
path: root/src/common/util.h
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@ev0ke.net>2015-02-16 15:55:30 -0500
committerteor <teor2345@gmail.com>2015-05-06 18:05:16 +1000
commit8acccdbeac69b066be805f711133e188a7b04f28 (patch)
tree1d7e685781506b75946d6cdd1f4f61da2580deef /src/common/util.h
parentdad5eb7e1f3c92974c7bcaaea325a05233a27494 (diff)
downloadtor-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.h1
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