public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "vincent-gcc at vinc17 dot net" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug gcov-profile/53915] gcov -f rounding problem Date: Tue, 10 Jul 2012 14:27:00 -0000 [thread overview] Message-ID: <bug-53915-4-Yi24Mpj4Zg@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-53915-4@http.gcc.gnu.org/bugzilla/> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53915 --- Comment #1 from Vincent Lefèvre <vincent-gcc at vinc17 dot net> 2012-07-10 14:27:28 UTC --- The problem is probably in gcc/gcov.c, function format_gcov, which has: float ratio = bottom ? (float)top / bottom : 0; int ix; unsigned limit = 100; unsigned percent; for (ix = dp; ix--; ) limit *= 10; percent = (unsigned) (ratio * limit + (float)0.5); Using double instead of float would be a first improvement (2 occurrences in the first line, cast to be removed in the last line). Also, multiplying top by limit (after a cast to double) before dividing by bottom should be better, as the first operation (the multiplication) would be done exactly in practice. Something like that: percent = (unsigned) ((double) top * limit / bottom + 0.5); or even: percent = (unsigned) (((double) top * limit + (double) bottom / 2) / bottom);
next prev parent reply other threads:[~2012-07-10 14:27 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-07-10 13:32 [Bug gcov-profile/53915] New: " vincent-gcc at vinc17 dot net 2012-07-10 14:27 ` vincent-gcc at vinc17 dot net [this message] 2012-07-10 14:46 ` [Bug gcov-profile/53915] " vincent-gcc at vinc17 dot net 2012-07-10 15:19 ` [Bug gcov-profile/53915] gcov can call format_gcov with top > bottom, which is unexpected vincent-gcc at vinc17 dot net 2012-07-11 7:44 ` [Bug gcov-profile/53915] gcov can call format_gcov with top > bottom, which is unexpected and gives 99.99% rguenth at gcc dot gnu.org 2012-07-22 0:15 ` steven at gcc dot gnu.org
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=bug-53915-4-Yi24Mpj4Zg@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /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: linkBe 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 read-only IMAP folder(s) and NNTP newsgroup(s).