From d7c4537f2aff5772ba7802049954fa81e0b019d6 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sat, 26 Sep 2009 04:24:45 +0000 Subject: [PATCH] (trunk, libT) #2379: infinite ratio shows as nan, invalid json --- libtransmission/utils.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libtransmission/utils.c b/libtransmission/utils.c index 761006ed4..fec852ac8 100644 --- a/libtransmission/utils.c +++ b/libtransmission/utils.c @@ -1328,8 +1328,9 @@ tr_parseNumberRange( const char * str_in, int len, int * setmeCount ) double tr_truncd( double x, int decimal_places ) { - const int i = (int) pow( 10, decimal_places ); - double x2 = (int)(x*i); + static const int multiplier[] = { 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000 }; + const int64_t i = multiplier[decimal_places]; + double x2 = (int64_t)(x*i); return x2 / i; }