Is the author implying Rust's default rounding behavior is a bad default? In what world is "ties to even" a GOOD default?
https://en.wikipedia.org/wiki/Rounding#Rounding_half_to_even
So for a video upload from a photo app it's not at all unreasonable to make the first 50% the transcoding step and the second 50% the actual upload and show progress of each step within those percentages. Some people may read this with horror; the transcoding step might be much faster/slower! It's not accurate! But the point is the user can at least see progress/no progress. You aren't allowing an upload bar to sit at 0% because you prioritised a % accurate upload over a progress bar that represents all stages of progress. It's better the progress bar move faster/slower at various stages than a progress bar that simply misses stages.
This goes for loading screens that sit at 100% for a while too. I'd prefer if they reserved some percentage of the loading bar for those 'post 100%' steps and continued to show progress. End users won't care if it's not all the same speed as much as they'll care about stuck progress bars.
The label on the progress bar should be "12345 out of 23456 files copied" and not 53% for this reason.
That way you can see if it hanged even if the progress is very slow.
Besides - the percentage label is redundant - the bar shows it graphically anyway.
You can't see if this is 99% or not.
All digits even become difficult with large numbers: 175.464.272 of 175.484.272 downloaded (i.e. not 100%).
hm ...
>>> def percent(progress, total):
... return round(99 * progress / total + 0.5)
...
>>> x = 9007199254740990.0
>>> x - 1 < x
True
>>> percent(x - 1, x)
100 >>> x = 9007199254740990
>>> percent(x - 1, x)
99
But then again, >>> percent(10 * x - 1, 10 * x)
100
If your procedure has 2^53 steps, feel free to ignore my rounding recommendations, since I'll never see it get anywhere near 100% :)Also if your username is named after the band, good taste :)
i am not cheating; you are cheating by trying to do integer arithmetic instead of float arithmetic. in particular: 99 * progress is a (potentially big) integer; then the quotient, from my understanding of python, is equal to the mathematical quantity rn(99 * progress / total), which is not trivial to compute. (although cpython does tend to do a particularly bad job of this sort of thing.) (compare with c or with my version of the python, where it would be rn(rn(99 * progress) / rn(total)), rounding twice, which is very easy to compute. i'm not saying the c semantics is better, mind.) when you scale up by 10x, the numerator is <1/2 'ulp' away from the denominator, and so the quotient rounds up to 99 exactly; there is still double rounding (would have been triple rounding in c and my python), because we got rn(rn(99 * progress / total) + 0.5) where what we wanted was rn(99 * progress / total + 0.5) (which is mathematically always the correct result)
i agree it is not common to have so many steps. but if i were providing a routine that was intended to be robust where others were not, i would try to be comprehensive. and i would not try to do int math with floats unless i could show it to be robust (i have sketched such a stunt! https://gist.github.com/moon-chilled/60bd2ba687dc197d93a9d22...). the integer routine is simpler and more honest anyway, and it is obvious that it works uniformly for the entire range
note also that, with x floating, the python expressions 10 * x and 10 * x - 1 are equivalent, meaning the error is on input to the percent function. (if we set progress to 10 * x - 8, the immediately preceding fp number, we do get 99, but there is no deep reason for this, and it differs for different values of 10.)
> if your username is named after the band, good taste :)
my username comes from a book: the neverending story. i am more using the german version of the name these days but i do not feel like making a new account on this godforesaken website
If the UI automatically transitions to a totally new screen after completion, I'm never going to see 100% anyways, unless the app does the exact infuriating thing in TFA, which is render 100% (at 99.whatever) and then do some fsync/cleanup and actually be frozen showing 100% which is the contrapositive of oddly satisfying, it's unsurprisingly unsatisfying.
Feels like having some standard plan + execution status interface would at least force you to consider a whole process even if that multistep plan is basically hardcoded.
Personally, "0%" doesn't mean "hasn't started" to me, it means "not enough progress has happened to reach 1%". Assuming I'm not alone with that, the rounding becomes a simple truncation `roundedPercent = int(percent)`
An implementation as simple as the concept, which is a good sign in my experience
But then, I'm a Unix hacker. ;)