Changeset 8016
- Timestamp:
- Mar 4, 2009, 4:02:50 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/daemon/remote.c
r7992 r8016 659 659 #define GIGABYTE_FACTOR ( 1024.0 * 1024.0 * 1024.0 ) 660 660 661 static void 662 printf_double_without_rounding( char * buf, int buflen, double d, int places ) 663 { 664 char * pch; 665 char tmp[128]; 666 int len; 667 tr_snprintf( tmp, sizeof( tmp ), "%'.64f", d ); 668 pch = strchr( tmp, '.' ); 669 pch += places + 1; 670 len = MIN( buflen - 1, pch - tmp ); 671 memcpy( buf, tmp, len ); 672 buf[len] = '\0'; 673 } 674 661 675 static char* 662 676 strlratio2( char * buf, double ratio, size_t buflen ) … … 667 681 tr_strlcpy( buf, "Inf", buflen ); 668 682 else if( ratio < 10.0 ) 669 tr_snprintf( buf, buflen, "%'.2f", ratio);683 printf_double_without_rounding( buf, buflen, ratio, 2 ); 670 684 else if( ratio < 100.0 ) 671 tr_snprintf( buf, buflen, "%'.1f", ratio);685 printf_double_without_rounding( buf, buflen, ratio, 1 ); 672 686 else 673 687 tr_snprintf( buf, buflen, "%'.0f", ratio );
Note: See TracChangeset
for help on using the changeset viewer.