util: add UTI_Log2ToDouble()

This commit is contained in:
Miroslav Lichvar
2015-05-28 12:34:08 +02:00
parent cde3a003ea
commit 3c217a9e37
3 changed files with 21 additions and 11 deletions

16
util.c
View File

@@ -643,6 +643,22 @@ UTI_IsTimeOffsetSane(struct timeval *tv, double offset)
/* ================================================== */
double
UTI_Log2ToDouble(int l)
{
if (l >= 0) {
if (l > 31)
l = 31;
return 1 << l;
} else {
if (l < -31)
l = -31;
return 1.0 / (1 << -l);
}
}
/* ================================================== */
void
UTI_TimevalNetworkToHost(Timeval *src, struct timeval *dest)
{