Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#2271 closed Bug (fixed)

rounding problem in printf()

Reported by: costela Owned by: charles
Priority: Low Milestone: None Set
Component: Transmission Version: 1.72
Severity: Minor Keywords: rouding, percentage
Cc:

Description

As reported in the Debian bug, transmission could round the done percentage down and the time remaining up, to avoid the awkward seconds of "100% done, but still downloading".

I attached a small patch to tentatively deal with at least the percentage part of the problem. It's not ideal cause it assumes a precision of 2 to avoid rounding by printf. Perhaps for that reason it would be better to put it inside getProgressString instead of tr_getRatio, so libtransmission didn't make assumptions for the interfaces (the CLI interface, for instance, rounds to just 1 digit and would continue with the problem). What do you think?

As a side note, wouldn't it be more intuitive if percentDone and percendComplete actually held percentages, instead of ratios? Or alternative if they were renamed to ratioDone and ratioComplete, respectively? Yeah, I know that's nitpicking :)

Cheers

Attachments (1)

percent_round_problem.patch (595 bytes) - added by costela 12 years ago.

Download all attachments as: .zip

Change History (8)

Changed 12 years ago by costela

comment:1 Changed 12 years ago by livings124

I'm not sure changing this is the *right thing to do*. Perhaps the 0 time left and 100% left could be a little confusing, but it is accurate and, more importantly, consistent.

comment:2 Changed 12 years ago by costela

What do you mean with consistent? As for accurate, mathematically perhaps, but if you have a big and badly seeded torrent there's a reasonably good chance the "100%" might last for minutes, so I'm not sure that can be called accurate.

As for the time issue: the chance of seeing "0 seconds left" is smaller, so I admit it's not particularly confusing and could be ignored. It is also - by definition - an estimation, so it's fair to expect a larger degree of inaccuracy.

But of course, this is ultimately your call. I'm not particularly adamant about this issue (and even less about the solution), so I'm playing a bit of devil's advocate...

comment:3 Changed 12 years ago by livings124

By consistent I mean all the numbers are rounded the same way. On the other hand, I always assumed progress was truncated, so I'm a bit surprised it's showing 100% instead of 99%.

comment:4 Changed 12 years ago by costela

It's an easy test to make, just try:

printf("%.2f\n",99.99) --> shows 99.99 printf("%.2f\n",99.999) --> shows 100.00

This could be arch specific, but I admit I couldn't find much reading regarding printf's rounding behavior in that sense.

comment:5 Changed 12 years ago by charles

  • Owner set to charles
  • Status changed from new to assigned
  • Summary changed from Rounding problem to rounding problem in printf()

fixed in trunk by r8808 for 1.73

comment:6 Changed 12 years ago by charles

  • Resolution set to fixed
  • Status changed from assigned to closed

comment:7 Changed 12 years ago by charles

added tr_truncd() unit test in r8809

Note: See TracTickets for help on using tickets.