CLOVIS
05/13/2026, 1:12 PMDuration.toString() with only decimals = ?
I often want to display different durations but I don't particularly care about precision. The existing toString() forces me to specify the unit, but I want to keep the default 'choose the unit automatically' behavior.
Example data:
actualElapsed=100.355299ms
actualElapsed=203.587405ms
actualElapsed=304.010250ms
actualElapsed=404.457431ms
actualElapsed=505.196217ms
…
actualElapsed=1.412863722s
actualElapsed=1.514498612s
actualElapsed=1.615550814s
I'd prefer to display it as:
actualElapsed=100.4ms
actualElapsed=203.6ms
actualElapsed=304.0ms
actualElapsed=404.5ms
actualElapsed=505.2ms
…
actualElapsed=1.4s
actualElapsed=1.5s
actualElapsed=1.6s
This is because in this particular situation, at-a-glance reading is more important than the precision of the value.Klitos Kyriacou
05/14/2026, 9:10 AMactualElapsed=995.2ms -- could be between 995.15 and 995.25 ms - a range of 0.1 ms
actualElapsed=1.1s -- could be between 1050 and 1150 ms - a range of 100 ms
The durations are of very similar values, yet the precision is grossly different.CLOVIS
05/14/2026, 10:22 AMFilipp Zhinkin
05/14/2026, 3:14 PMFilipp Zhinkin
05/19/2026, 1:43 PMCLOVIS
05/26/2026, 12:39 PM