http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47913
--- Comment #6 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-03-01 23:00:05 UTC --- Thanks again for your help on this. Preliminarily, a few observations: 1- Please make sure the code is minimally documented (are the comments in longlong.h enough?); 2- I see stuff like __builtin_clzll(__d) on __d a uintmax_t, I'm not sure it's always ok, on any 32-bit and 64-bit target. More generally - I'm asking to Marc the mathematician here, not Mark the libstdc++ contributor - do we have a clear characterization of which specific overflows can be avoided? Are we *really* sure the boost::rational implementation is equivalent to GCC and weaker than what you are proposing: the first time I looked into it I remember seeing a normalization happening earlier toward the end, per the last two lines of that comment: // Which proves that instead of normalizing the result, it is better to // divide num and den by gcd((a*d1 + c*b1), g)