public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/47913] New: [C++0x] improve ratio_add to overflow less often
@ 2011-02-27 13:23 marc.glisse at normalesup dot org
  2011-02-27 14:13 ` [Bug libstdc++/47913] " paolo.carlini at oracle dot com
                   ` (24 more replies)
  0 siblings, 25 replies; 26+ messages in thread
From: marc.glisse at normalesup dot org @ 2011-02-27 13:23 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47913

           Summary: [C++0x] improve ratio_add to overflow less often
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: marc.glisse@normalesup.org


ratio_add currently computes something like:
gcd=gcd(den1,den2)
num=num1*(den2/gcd)+num2*(den1/gcd)
den=den1*(den2/gcd)
gcd2=gcd(num,den)
num/=gcd2
den/=gcd2

In cases where gcd2 is not 1, the computation may overflow whereas the final
result would fit. Even without that, it is possible that one or both of the
terms added in num are too large but their sum is not.

As a quality of implementation issue, it would be nice to reduce those cases a
bit. But that comes far far behind the ratio_less improvement described in PR
42622.


^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2011-05-04 23:36 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-27 13:23 [Bug libstdc++/47913] New: [C++0x] improve ratio_add to overflow less often marc.glisse at normalesup dot org
2011-02-27 14:13 ` [Bug libstdc++/47913] " paolo.carlini at oracle dot com
2011-02-27 19:33 ` marc.glisse at normalesup dot org
2011-02-27 23:38 ` paolo.carlini at oracle dot com
2011-02-28  1:33 ` paolo.carlini at oracle dot com
2011-03-01 22:16 ` marc.glisse at normalesup dot org
2011-03-01 23:00 ` paolo.carlini at oracle dot com
2011-03-02 10:00 ` marc.glisse at normalesup dot org
2011-03-02 10:59 ` paolo.carlini at oracle dot com
2011-03-02 11:50 ` marc.glisse at normalesup dot org
2011-03-02 11:54 ` marc.glisse at normalesup dot org
2011-03-02 11:59 ` paolo.carlini at oracle dot com
2011-03-02 12:07 ` paolo.carlini at oracle dot com
2011-03-02 14:05 ` marc.glisse at normalesup dot org
2011-03-02 14:15 ` paolo.carlini at oracle dot com
2011-03-02 14:58 ` paolo at gcc dot gnu.org
2011-03-02 14:59 ` paolo.carlini at oracle dot com
2011-03-02 20:50 ` marc.glisse at normalesup dot org
2011-03-02 23:21 ` paolo.carlini at oracle dot com
2011-03-03  6:41 ` marc.glisse at normalesup dot org
2011-03-03  9:51 ` paolo.carlini at oracle dot com
2011-05-04 16:35 ` marc.glisse at normalesup dot org
2011-05-04 17:05 ` paolo.carlini at oracle dot com
2011-05-04 18:08 ` paolo.carlini at oracle dot com
2011-05-04 23:28 ` paolo at gcc dot gnu.org
2011-05-04 23:36 ` paolo.carlini at oracle dot com

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).