From: David Kastrup <dak@gnu.org>
To: "René Scharfe" <rene.scharfe@lsrfire.ath.cx>
Cc: Junio C Hamano <junkio@cox.net>,
Johannes Schindelin <Johannes.Schindelin@gmx.de>,
Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH] diff: round down similarity index
Date: Mon, 25 Jun 2007 07:08:54 +0200 [thread overview]
Message-ID: <85y7i8boyh.fsf@lola.goethe.zz> (raw)
In-Reply-To: <467EEEE6.3090100@lsrfire.ath.cx> ("René Scharfe"'s message of "Mon\, 25 Jun 2007 00\:23\:34 +0200")
René Scharfe <rene.scharfe@lsrfire.ath.cx> writes:
> +static int similarity_index(struct diff_filepair *p)
> +{
> + int result = p->score * 100.0 / MAX_SCORE;
Use floor(p->score ... MAX_SCORE) here: I don't think that C otherwise
specifies a preferred way of rounding on float->int conversions.
> + /* Paranoia: guard against floating point rounding errors. */
> + if (p->score == MAX_SCORE)
> + result = 100;
> + else if (result == 100)
> + result = 99;
Also, p->score itself must be calculated by truncating.
--
David Kastrup, Kriemhildstr. 15, 44793 Bochum
next prev parent reply other threads:[~2007-06-25 5:09 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-24 22:23 [PATCH] diff: round down similarity index René Scharfe
2007-06-24 23:25 ` Johannes Schindelin
2007-06-24 23:27 ` Johannes Schindelin
2007-06-25 1:29 ` René Scharfe
2007-06-25 5:08 ` David Kastrup [this message]
2007-06-25 6:18 ` Junio C Hamano
[not found] ` <86k5tsh761.fsf@lola.quinscape.zz>
2007-06-25 10:34 ` René Scharfe
2007-06-25 10:34 ` [PATCH] diff: round down similarity index, take 2 René Scharfe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=85y7i8boyh.fsf@lola.goethe.zz \
--to=dak@gnu.org \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=junkio@cox.net \
--cc=rene.scharfe@lsrfire.ath.cx \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).