Tor 0.4.9.0-alpha-dev
Functions
fp.c File Reference

Basic floating-point compatibility and convenience code. More...

#include "orconfig.h"
#include "lib/math/fp.h"
#include <math.h>

Go to the source code of this file.

Functions

double tor_mathlog (double d)
 
long tor_lround (double d)
 
int64_t tor_llround (double d)
 
int64_t clamp_double_to_int64 (double number)
 
int tor_isinf (double x)
 

Detailed Description

Basic floating-point compatibility and convenience code.

Definition in file fp.c.

Function Documentation

◆ clamp_double_to_int64()

int64_t clamp_double_to_int64 ( double  number)

Cast a given double value to a int64_t. Return 0 if number is NaN. Returns either INT64_MIN or INT64_MAX if number is outside of the int64_t range.

Definition at line 61 of file fp.c.

Referenced by sample_laplace_distribution().

◆ tor_isinf()

int tor_isinf ( double  x)

Definition at line 127 of file fp.c.

◆ tor_llround()

int64_t tor_llround ( double  d)

Return the 64-bit integer closest to d. We define this wrapper here so that not all users of math.h need to use the right incantations to get the c99 functions.

Definition at line 46 of file fp.c.

Referenced by fill_cc_gauges_values(), and scale_array_elements_to_u64().

◆ tor_lround()

long tor_lround ( double  d)

Return the long integer closest to d. We define this wrapper here so that not all users of math.h need to use the right incantations to get the c99 functions.

Definition at line 31 of file fp.c.

Referenced by circuit_build_times_close_quantile(), and circuit_build_times_set_timeout().

◆ tor_mathlog()

double tor_mathlog ( double  d)

Returns the natural logarithm of d base e. We defined this wrapper here so to avoid conflicts with old versions of tor_log(), which were named log().

Definition at line 22 of file fp.c.

Referenced by circuit_build_times_update_alpha(), and sample_laplace_distribution().