1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-24 16:52:39 +00:00

(trunk, libT) #2379: infinite ratio shows as nan, invalid json

This commit is contained in:
Charles Kerr 2009-09-26 04:24:45 +00:00
parent 52f212fc9a
commit d7c4537f2a

View file

@ -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;
}