New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Demonstrate interoperability with Boost.Rational #34
Comments
Good call. I had thought of other cases like atomic<safe<int> > and
perhaps others.
…On 3/11/17 5:36 AM, Andrzej Krzemieński wrote:
The following example, which tests usage of |rational<safe<int>>|
works fine. I would recommend adding a test like this in the library,
and the examples list.
#include <safe_integer.hpp>
#include <iostream>
#include <limits>
#include <boost/rational.hpp>
int main(int argc,const char * argv[])
{
using SafeRatio = boost::rational<boost::numeric::safe<int>>;
SafeRatio r {1,2};
SafeRatio q {-2,4};
std::cout << (r * q) << std::endl;
auto a = r * q;
assert ((a == SafeRatio{-1,4}));
SafeRatio x {1, INT_MAX};
SafeRatio y {1,2};
try {
x * y;
assert (false);
}
catch (std::exceptionconst& e) {
assert (true);
std::cout << e.what() << std::endl;
}
x *=2;
x /=2;
assert ((x == SafeRatio{1, INT_MAX}));
return 0;
}
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#34>, or mute the
thread
<https://github.com/notifications/unsubscribe-auth/AB4R3CQ7x6VWqQrpApFAbKuUVANELxVpks5rkqNwgaJpZM4MaNJd>.
--
Robert Ramey
www.rrsd.com
(805)569-3793
|
I had remembered to add test/example for using with rational but had forgotten that you included a working demo right here. Now when I try this test, it doesn't work on my current version of the library. I've made many, many corrections to the library in accordance with the review conditions and it seems that something has gotten lost in the shuffle. I'm still looking into this. |
fixed - see example 15 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The following example, which tests usage of
rational<safe<int>>
works fine. I would recommend adding a test like this in the library, and the examples list.The text was updated successfully, but these errors were encountered: