Ignore:
Timestamp:
Oct 17, 2010, 6:27:42 PM (11 years ago)
Author:
charles
Message:

(trunk libT) #3521 "rounding issue in tr_truncd()" -- this time for sure...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/utils.c

    r11299 r11331  
    14341434tr_truncd( double x, int decimal_places )
    14351435{
     1436    /* sigh... surely there's a better way to do this */
     1437    char buf[1024];
    14361438    const int i = (int) pow( 10, decimal_places );
    1437     return floor( x * i ) / i;
     1439    snprintf( buf, sizeof( buf ), "%f", x*i );
     1440    *strchr(buf,'.') = '\0';
     1441    return atof(buf) / i;
    14381442}
    14391443
Note: See TracChangeset for help on using the changeset viewer.