GitHub PullRequestReviewCommentEvent at 2014-06-05 18:50:00
Repository: csympy
Actor: certik
Payload: {"comment":{"url":"https://api.github.com/repos/sympy/csympy/pulls/comments/13457474","id":13457474,"diff_hunk":"@@ -98,8 +98,26 @@ RCP<const Basic> pow(const RCP<const Basic> &a, const RCP<const Basic> &b)\n     if (eq(a, one)) return one;\n     if (eq(a, minus_one) && is_a<Integer>(*b))\n         return is_a<Integer>(*div(b, integer(2))) ? one : minus_one;\n-    if (is_a_Number(*a) && is_a<Integer>(*b))\n-        return pownum(rcp_static_cast<const Number>(a), rcp_static_cast<const Integer>(b));\n+    if (is_a_Number(*a) && is_a_Number(*b)) {\n+        RCP<const Number> exp_new = rcp_static_cast<const Number>(b);\n+        if(exp_new->is_negative()) {\n+            exp_new = exp_new->mul(*(rcp_static_cast<const Number>(minus_one)));\n+            if (is_a<Integer>(*b)) {\n+                return pownum(rcp_static_cast<const Number>(a)->rdiv(*rcp_static_cast<const Number>(one)),\n+                rcp_static_cast<const Integer>(b)->mul(*rcp_static_cast<const Number>(minus_one)));\n+            }\n+            else if (is_a<Rational>(*b)) {\n+                return rcp(new Pow(rcp_static_cast<const Number>(a)->rdiv(*rcp_static_cast<const Number>(one)),\n+                rcp_static_cast<const Integer>(b)->mul(*rcp_static_cast<const Number>(minus_one))));","path":"src/pow.cpp","position":16,"original_position":16,"commit_id":"fbe0310b5116ccce57937cbfe53a59d227325782","original_commit_id":"fbe0310b5116ccce57937cbfe53a59d227325782","user":{"login":"certik","id":20568,"avatar_url":"https://avatars.githubusercontent.com/u/20568?","gravatar_id":"29d62e4d73bf4a16a7755f6862a6031f","url":"https://api.github.com/users/certik","html_url":"https://github.com/certik","followers_url":"https://api.github.com/users/certik/followers","following_url":"https://api.github.com/users/certik/following{/other_user}","gists_url":"https://api.github.com/users/certik/gists{/gist_id}","starred_url":"https://api.github.com/users/certik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/certik/subscriptions","organizations_url":"https://api.github.com/users/certik/orgs","repos_url":"https://api.github.com/users/certik/repos","events_url":"https://api.github.com/users/certik/events{/privacy}","received_events_url":"https://api.github.com/users/certik/received_events","type":"User","site_admin":false},"body":"It should be clarified in comments what the code is doing.","created_at":"2014-06-05T18:50:00Z","updated_at":"2014-06-05T18:50:00Z","html_url":"https://github.com/sympy/csympy/pull/182#discussion_r13457474","pull_request_url":"https://api.github.com/repos/sympy/csympy/pulls/182","_links":{"self":{"href":"https://api.github.com/repos/sympy/csympy/pulls/comments/13457474"},"html":{"href":"https://github.com/sympy/csympy/pull/182#discussion_r13457474"},"pull_request":{"href":"https://api.github.com/repos/sympy/csympy/pulls/182"}}}}