Rational Number Class

Rational Number Class


Rational Number Class Github

I need some feed back, could this become a standard? is it usable? should I make a Mandelbrot renderer to test it???

Any feedback is helpful


Not sure the point of your post. You posted in Project Feedback, but provided no application or code for review.


Just edit your original post.


I don’t think this is entirely useful, for similar reasons as outlined here: http://www.boost.org/doc/libs/1_64_0/libs/rational/rational.html

There is no consensus on the best way to represent a floating point as a fraction and preserve all the properties people want. It’s not too difficult to add the “correct” method yourself for each application specifically.

For example, some people would want float_to_rational(1.0/3.0) to equal 1/3, whereas some people would want the literal float representation 33333333333333331/100000000000000000. (example from above)

The makers of boost::rational decided not to implement that single function given that problem.

So to answer your questions with my opinion:

No, this can’t become a standard because there’s already no universal agreement, for good reasons from all sides;

Yes it’s usable as long as you understand how the conversion works and any limitations (not having the most accurate representation of pi is a little worrisome for many applications)

It would be interesting to see a Mandelbrot renderer comparison I guess? Not essential for testing but why not :slight_smile:


float_to_rational(1.0/3.0) to equal 1/3