Re: [PATCH] diff: round down similarity index

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Mon, 25 Jun 2007, Johannes Schindelin wrote:

> On Mon, 25 Jun 2007, Ren�charfe wrote:
> 
> > Rounding down the printed (dis)similarity index allows us to use
> > "100%" as a special value that indicates complete rewrites and
> > fully equal file contents, respectively.
> >
> > [...]
> > 
> > +static int similarity_index(struct diff_filepair *p)
> > +{
> > +	int result = p->score * 100.0 / MAX_SCORE;
> > +
> > +	/* Paranoia: guard against floating point rounding errors. */
> > +	if (p->score == MAX_SCORE)
> > +		result = 100;
> > +	else if (result == 100)
> > +		result = 99;
> > +
> > +	return result;
> > +}
> 
> That's not even properly rounding down. The correct formula (correct in 
> the sense for "what you want") would be
> 
> 	p->score * 100.0 / MAX_SCORE
> 
> if p->score == MAX_SCORE, iff the files are identical. And yes, that is 
> the old formula.

Just ignore that, please.

> Besides, AFAIR p->score is not even calculated if the files are identical, 
> because that hits a different code path.

But this still holds true.

Ciao,
Dscho

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux