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
Add pow method #21
Add pow method #21
Conversation
include/boost/rational.hpp
Outdated
@@ -146,6 +146,9 @@ class rational | |||
struct helper { IntType parts[2]; }; | |||
typedef IntType (helper::* bool_type)[2]; | |||
|
|||
class already_normalized {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be a public constructor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can leave it this way for now (private).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It turns out this is no longer necessary with the removal of reciprocal().
Other than my one comment, this looks fine. I'd be really tempted to remove the Metrowerks 8.3 workarounds, though. That compiler was released in 2002/2003. |
Codecov Report
@@ Coverage Diff @@
## develop #21 +/- ##
===========================================
- Coverage 67.52% 67.25% -0.27%
===========================================
Files 1 1
Lines 271 281 +10
Branches 90 97 +7
===========================================
+ Hits 183 189 +6
Misses 3 3
- Partials 85 89 +4
Continue to review full report at Codecov.
|
AMDG
On 06/14/2018 06:47 AM, James E. King III wrote:
@jeking3 requested your review on: boostorg/rational#21 Add pow and reciprocal methods.
I'm somewhat unconvinced of the value of x.reciprocal()
as opposed to 1/x, which I believe is more clear.
In Christ,
Steven Watanabe
|
@swatanabe I'm not sure I understand what you mean by the |
AMDG
On 06/14/2018 02:18 PM, James E. King III wrote:
@swatanabe I'm not sure I understand what you mean by the `1/x` in the boost::rational context. Without a reciprocal() call, the only way I see to do it otherwise is to call `1.0/rational_cast<double>(r)`, and then you are stuck with a double and no good way to get back to a rational<>IntType> again.
Why would you need to use double? There's
an operator/(CompatibleIntType, rational<IntType>)
In Christ,
Steven Watanabe
|
c097503
to
c6d9a20
Compare
I removed reciprocal() and used your suggestion, so the addition is just pow(..) now. |
It looks like this may have caused some issues in poorly scoped calls to pow() - see: Any suggestions? Should Boost.Spirit be more specific? |
The original author of #9 deleted their repository. I applied the change manually.
This closes #9