Commit 0a34ae55 authored by Thomas Haller's avatar Thomas Haller

core/trivial: rename nm_utils_10pow() to nm_utils_exp10()

nm_utils_exp10() is a better name, because it reminds of the function
exp10() from <math.h> which has a similar purpose (but whose argument
is double, not gint16).
parent 29a47f40
......@@ -156,14 +156,14 @@ _nm_singleton_instance_register_destruction (GObject *instance)
/*****************************************************************************/
static double
_10pow (guint16 ex)
_exp10 (guint16 ex)
{
double v;
if (ex == 0)
return 1.0;
v = _10pow (ex / 2);
v = _exp10 (ex / 2);
v = v * v;
if (ex % 2)
v *= 10;
......@@ -171,17 +171,17 @@ _10pow (guint16 ex)
}
/*/
* nm_utils_10pow:
* nm_utils_exp10:
* @ex: the exponent
*
* Returns: 10^ex or pow(10, ex)
* Returns: 10^ex, or pow(10, ex), or exp10(ex).
*/
double
nm_utils_10pow (gint16 ex)
nm_utils_exp10 (gint16 ex)
{
if (ex >= 0)
return _10pow (ex);
return 1.0 / _10pow (- ((gint32) ex));
return _exp10 (ex);
return 1.0 / _exp10 (- ((gint32) ex));
}
/*****************************************************************************/
......
......@@ -97,7 +97,7 @@ in_addr_t nm_utils_ip4_address_clear_host_address (in_addr_t addr, guint8 plen);
const struct in6_addr *nm_utils_ip6_address_clear_host_address (struct in6_addr *dst, const struct in6_addr *src, guint8 plen);
gboolean nm_utils_ip6_address_same_prefix (const struct in6_addr *addr_a, const struct in6_addr *addr_b, guint8 plen);
double nm_utils_10pow (gint16 e);
double nm_utils_exp10 (gint16 e);
/**
* nm_utils_ip6_route_metric_normalize:
......
......@@ -89,7 +89,7 @@ iw_freq_to_uint32 (const struct iw_freq *freq)
else if (freq->m == 14)
return 2484;
}
return (guint32) ((((double) freq->m) * nm_utils_10pow (freq->e)) / 1000000.0);
return (guint32) ((((double) freq->m) * nm_utils_exp10 (freq->e)) / 1000000.0);
}
static void
......
......@@ -1657,7 +1657,7 @@ test_stable_id_generated_complete (void)
/*****************************************************************************/
static void
test_nm_utils_10pow (void)
test_nm_utils_exp10 (void)
{
#define FLOAT_CMP(a, b) \
G_STMT_START { \
......@@ -1677,28 +1677,28 @@ test_nm_utils_10pow (void)
} \
} G_STMT_END
FLOAT_CMP (nm_utils_10pow (G_MININT16), 0.0);
FLOAT_CMP (nm_utils_10pow (-310), 0.0);
FLOAT_CMP (nm_utils_10pow (-309), 0.0);
FLOAT_CMP (nm_utils_10pow (-308), 1e-308);
FLOAT_CMP (nm_utils_10pow (-307), 1e-307);
FLOAT_CMP (nm_utils_10pow (-1), 1e-1);
FLOAT_CMP (nm_utils_10pow (-2), 1e-2);
FLOAT_CMP (nm_utils_10pow (0), 1e0);
FLOAT_CMP (nm_utils_10pow (1), 1e1);
FLOAT_CMP (nm_utils_10pow (2), 1e2);
FLOAT_CMP (nm_utils_10pow (3), 1e3);
FLOAT_CMP (nm_utils_10pow (4), 1e4);
FLOAT_CMP (nm_utils_10pow (5), 1e5);
FLOAT_CMP (nm_utils_10pow (6), 1e6);
FLOAT_CMP (nm_utils_10pow (7), 1e7);
FLOAT_CMP (nm_utils_10pow (122), 1e122);
FLOAT_CMP (nm_utils_10pow (200), 1e200);
FLOAT_CMP (nm_utils_10pow (307), 1e307);
FLOAT_CMP (nm_utils_10pow (308), 1e308);
FLOAT_CMP (nm_utils_10pow (309), INFINITY);
FLOAT_CMP (nm_utils_10pow (310), INFINITY);
FLOAT_CMP (nm_utils_10pow (G_MAXINT16), INFINITY);
FLOAT_CMP (nm_utils_exp10 (G_MININT16), 0.0);
FLOAT_CMP (nm_utils_exp10 (-310), 0.0);
FLOAT_CMP (nm_utils_exp10 (-309), 0.0);
FLOAT_CMP (nm_utils_exp10 (-308), 1e-308);
FLOAT_CMP (nm_utils_exp10 (-307), 1e-307);
FLOAT_CMP (nm_utils_exp10 (-1), 1e-1);
FLOAT_CMP (nm_utils_exp10 (-2), 1e-2);
FLOAT_CMP (nm_utils_exp10 (0), 1e0);
FLOAT_CMP (nm_utils_exp10 (1), 1e1);
FLOAT_CMP (nm_utils_exp10 (2), 1e2);
FLOAT_CMP (nm_utils_exp10 (3), 1e3);
FLOAT_CMP (nm_utils_exp10 (4), 1e4);
FLOAT_CMP (nm_utils_exp10 (5), 1e5);
FLOAT_CMP (nm_utils_exp10 (6), 1e6);
FLOAT_CMP (nm_utils_exp10 (7), 1e7);
FLOAT_CMP (nm_utils_exp10 (122), 1e122);
FLOAT_CMP (nm_utils_exp10 (200), 1e200);
FLOAT_CMP (nm_utils_exp10 (307), 1e307);
FLOAT_CMP (nm_utils_exp10 (308), 1e308);
FLOAT_CMP (nm_utils_exp10 (309), INFINITY);
FLOAT_CMP (nm_utils_exp10 (310), INFINITY);
FLOAT_CMP (nm_utils_exp10 (G_MAXINT16), INFINITY);
}
/*****************************************************************************/
......@@ -1716,7 +1716,7 @@ main (int argc, char **argv)
g_test_add_func ("/general/nm_utils_ip6_address_same_prefix", test_nm_utils_ip6_address_same_prefix);
g_test_add_func ("/general/nm_utils_log_connection_diff", test_nm_utils_log_connection_diff);
g_test_add_func ("/general/10pow", test_nm_utils_10pow);
g_test_add_func ("/general/exp10", test_nm_utils_exp10);
g_test_add_func ("/general/connection-match/basic", test_connection_match_basic);
g_test_add_func ("/general/connection-match/ip6-method", test_connection_match_ip6_method);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment