Changeset 4273
- Timestamp:
- Dec 22, 2007, 3:01:14 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gtk/util.c
r4271 r4273 62 62 }; 63 63 unsigned int i; 64 guint64small = size;65 for( i=0; i<G_N_ELEMENTS(units) && small>=1024; ++i )66 small >>= 10;64 double small = size; 65 for( i=0; i<G_N_ELEMENTS(units) && (small>=1024.0); ++i ) 66 small /= 1024.0; 67 67 if( i < 2 ) /* B & KiB */ 68 68 g_snprintf( buf, buflen, "%d %s", (int)small, _(units[i]) ); 69 69 else 70 g_snprintf( buf, buflen, "%.1f %s", (double)small, _(units[i]) );70 g_snprintf( buf, buflen, "%.1f %s", small, _(units[i]) ); 71 71 } 72 72 return buf; -
trunk/libtransmission/stats.c
r4143 r4273 133 133 } 134 134 135 static void 136 updateRatio( tr_session_stats * setme ) 137 { 138 if( setme->downloadedBytes ) 139 setme->ratio = setme->uploadedBytes / (double)setme->downloadedBytes; 140 else if( setme->uploadedBytes ) 141 setme->ratio = TR_RATIO_INF; 142 else 143 setme->ratio = TR_RATIO_NA; 144 } 145 135 146 void 136 147 tr_getSessionStats( const tr_handle * handle, … … 139 150 const struct tr_stats_handle * stats = handle->sessionStats; 140 151 *setme = stats->single; 141 142 setme->ratio = setme->downloadedBytes ? (double)setme->uploadedBytes / (double)setme->downloadedBytes143 : ( setme->uploadedBytes ? TR_RATIO_INF : TR_RATIO_NA );144 145 152 setme->secondsActive += ( time(NULL) - stats->startTime ); 153 updateRatio( setme ); 146 154 } 147 155 … … 152 160 const struct tr_stats_handle * stats = handle->sessionStats; 153 161 *setme = stats->cumulative; 154 setme->ratio = setme->downloadedBytes ? (double)setme->uploadedBytes / (double)setme->downloadedBytes : TR_RATIO_NA;155 162 setme->secondsActive += ( time(NULL) - stats->startTime ); 163 updateRatio( setme ); 156 164 } 157 165
Note: See TracChangeset
for help on using the changeset viewer.