[rational] with optional over/underflow checking

Hello, Would there be any interest in a modified "rational" class template/header that optionally allows for an exception be generated if there is under/overflow during any of the operations? I have been developing such a template, where the new defaulted bool template parameter would generate the class exactly as before to preserve the original stable implementation, and to support unlimited-precision integer where over/underflow would not be possible. Setting the new template parameter to true, however would generate code that adds the over/underflow checking. I have also generated new test driver code (BTW test code referenced by the documentation does not appear to exist, or at least the link is broken). rational.hpp has been around and stable for quite some time, so there may be a desire to keep it unchanged, but its original function (and indeed its original source code) can be maintained through the template system. If such a class were to be included in boost, what would be the best submission method?

-----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Dan Searles Sent: Monday, July 30, 2012 3:54 PM To: boost@lists.boost.org Subject: [boost] [rational] with optional over/underflow checking
Would there be any interest in a modified "rational" class template/header that optionally allows for an exception be generated if there is under/overflow during any of the operations? I have been developing such a template, where the new defaulted bool template parameter would generate the class exactly as before to preserve the original stable implementation, and to support unlimited-precision integer where over/underflow would not be possible. Setting the new template parameter to true, however would generate code that adds the over/underflow checking.
This must be useful, but must mesh with Multiprecision (provided Multiprecision is accepted). I'm sure John Maddock will have some views on this (if he isn't already plotting something ;-).
I have also generated new test driver code (BTW test code referenced by the documentation does not appear to exist, or at least the link is broken).
rational.hpp has been around and stable for quite some time, so there may be a desire to keep it unchanged, but its original function (and indeed its original source code) can be maintained
\boost-trunk\libs\rational\test\rational_test.cpp is being run by the testers. http://www.boost.org/development/tests/trunk/developer/rational.html You might like to attach your new test code? through the
template system.
Stability is useful, but like all software it needs maintenance, and this is yet another example of original authors now not being traceable. Several libraries need a new maintainer but currently we are dithering about the best process for this. Paul --- Paul A. Bristow, Prizet Farmhouse, Kendal LA8 8AB UK +44 1539 561830 07714330204 pbristow@hetp.u-net.com

Would there be any interest in a modified "rational" class template/header that optionally allows for an exception be generated if there is under/overflow during any of the operations? I have been developing such a template, where the new defaulted bool template parameter would generate the class exactly as before to preserve the original stable implementation, and to support unlimited-precision integer where over/underflow would not be possible. Setting the new template parameter to true, however would generate code that adds the over/underflow checking.
This must be useful, but must mesh with Multiprecision (provided Multiprecision is accepted).
I'm sure John Maddock will have some views on this (if he isn't already plotting something ;-).
I'm plotting on watching more Olympics ;-) This sounds like a good idea, but I'd just point out that I found the performance of Boost.Rational to be pretty abysmal, particularly when used with UDT's (lots and lots of copying at the very least). Can't help but wonder if there isn't a better way - assuming someone is willing to take it on! John.

John Maddock <boost.regex <at> virgin.net> writes:
Would there be any interest in a modified "rational" class template/header that optionally allows for an exception be generated if there is under/overflow during any of the operations? I have been developing such a template, where the new defaulted bool template parameter would generate the class exactly as before to preserve the original stable implementation, and to support unlimited-precision integer where over/underflow would not be possible. Setting the new template parameter to true, however would generate code that adds the over/underflow checking.
This must be useful, but must mesh with Multiprecision (provided Multiprecision is accepted).
I'm sure John Maddock will have some views on this (if he isn't already plotting something .
I'm plotting on watching more Olympics
This sounds like a good idea, but I'd just point out that I found the performance of Boost.Rational to be pretty abysmal, particularly when used with UDT's (lots and lots of copying at the very least). Can't help but wonder if there isn't a better way - assuming someone is willing to take it on!
John.
Speeding rational up could be done as well, but the original question was is there any interest in a rational that optionally supports over/underflow checking. As mentioned previously, the new template parameter would control if the checking code were generated, or the original implementation. The original implementation would be great for Multiprecision integer types, and in fact, the checking code should be prevented from being used if the integer type is Multiprecision (type trait checks would be used to insure this). I'm ready to submit this code (or code change), make changes/fixes, update test cases, etc. but what would be the proper channel? Via the sandbox area?, post a big diff? The last discussion I saw on rational was on about 12/12/04, so there is the question of a current maintainer in the mix as well.

Speeding rational up could be done as well, but the original question was is there any interest in a rational that optionally supports over/underflow checking. As mentioned previously, the new template parameter would control if the checking code were generated, or the original implementation. The original implementation would be great for Multiprecision integer types, and in fact, the checking code should be prevented from being used if the integer type is Multiprecision (type trait checks would be used to insure this). I'm ready to submit this code (or code change), make changes/fixes, update test cases, etc. but what would be the proper channel? Via the sandbox area?, post a big diff? The last discussion I saw on rational was on about 12/12/04, so there is the question of a current maintainer in the mix as well.
If there was a current maintainer, then filing a ticket or contacting them direct would be the way to go... as it is I suggest creating a modified version in the sandbox - I suspect that if you want to get a big-ish change accepted then you're more or less going to have to volunteer to become the next maintainer as well. Sorry! HTH, John.
participants (3)
-
Dan Searles
-
John Maddock
-
Paul A. Bristow