(trunk libT) #3521 "rounding issue in tr_truncd()" -- this time for sure...
This commit is contained in:
parent
14f8029fd1
commit
f3460eaea0
|
@ -1433,8 +1433,12 @@ tr_parseNumberRange( const char * str_in, int len, int * setmeCount )
|
|||
double
|
||||
tr_truncd( double x, int decimal_places )
|
||||
{
|
||||
/* sigh... surely there's a better way to do this */
|
||||
char buf[1024];
|
||||
const int i = (int) pow( 10, decimal_places );
|
||||
return floor( x * i ) / i;
|
||||
snprintf( buf, sizeof( buf ), "%f", x*i );
|
||||
*strchr(buf,'.') = '\0';
|
||||
return atof(buf) / i;
|
||||
}
|
||||
|
||||
char*
|
||||
|
|
Loading…
Reference in New Issue