From: Johan Herland Date: Wed, 27 Apr 2011 02:02:28 GMT Subject: Re: [PATCH 5/6] Use floating point for --dirstat percentages Message-ID: <201104270402.29085.johan@herland.net> In-Reply-To: <7vpqo9ez03.fsf@alter.siamese.dyndns.org> On Tuesday 26 April 2011, Junio C Hamano wrote: > Johan Herland writes: > > Allow specifying --dirstat cut-off percentage as a floating point > > number. > > > > When printing the dirstat output, floating point numbers are presented > > in rounded form (as opposed to truncated). > > Why isn't it sufficient to change > > permille = this_dir * 1000 / changed > > to > > permille = (this_dir * 2000 + changed) / (changed * 2) > > or something? If rounding is the only issue that bothers you (I admit > that it does bother me, now that you brought it up), that is. Actually, rounding doesn't bother me at all (or rather, I don't really care if we round or truncate, as long as we're consistent). It's just that once I s/strtoul/strtod/, and started propagating the "double"s through the code, I found that doing the final calculation and output with "double"s was more natural than the (somewhat hackish, IMHO) permille/percent thing. And that's when I finally came across the fact that "%6.1f" rounds whereas the earlier version truncated. I thought about it for a second, and figured that rounding was probably what most users expected. ...Johan -- Johan Herland, www.herland.net