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:
parent
52f212fc9a
commit
d7c4537f2a
1 changed files with 3 additions and 2 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue