{"action":"created","comment":{"url":"https://api.github.com/repos/ta4j/ta4j/pulls/comments/173636408","pull_request_review_id":102860235,"id":173636408,"diff_hunk":"@@ -181,6 +181,36 @@ public Num pow(int n) {\n         return new BigDecimalNum(delegate.pow(n, MATH_CONTEXT));\n     }\n \n+    /**\n+     * Returns a {@code Num} whose value is <tt>(this<sup>n</sup>)</tt>.\n+     * @param n power to raise this {@code Num} to.\n+     * @return <tt>this<sup>n</sup></tt>\n+     * @see BigDecimal#pow(int, java.math.MathContext)\n+     */\n+    public Num pow(Num n) {\n+        // Because BigDecimal.pow(BigDecimal) is not supported we need to find another way, we could do:\n+        // Math.pow(a.doubleValue(), b.doubleValue()), but there is a better way:\n+        // Perform X^(A+B)=X^A*X^B (B = remainder)\n+        // As suggested: https://stackoverflow.com/a/3590314\n+        BigDecimal result;\n+        BigDecimal power = ((BigDecimalNum)n).delegate;\n+        int signOfPower = power.signum();\n+        power = power.multiply(new BigDecimal(signOfPower));\n+\n+        BigDecimal remainderOf2 = power.remainder(BigDecimal.ONE);\n+        BigDecimal n2IntPart = power.subtract(remainderOf2);\n+\n+        BigDecimal intPow = delegate.pow(n2IntPart.intValueExact(), MATH_CONTEXT);\n+        BigDecimal doublePow = new BigDecimal(Math.pow(delegate.doubleValue(), remainderOf2.doubleValue()));\n+        result = intPow.multiply(doublePow);\n+\n+        if (signOfPower == -1) {\n+            result = BigDecimal.ONE.divide(result, MATH_CONTEXT);\n+        }\n+\n+        return new BigDecimalNum(result);\n+    }\n+\n     /**\n      * Returns the correctly rounded positive square root of the <code>double</code> value of this {@code Num}.\n      * /!\\ Warning! Uses the {@code StrictMath#sqrt(double)} method under the hood.","path":"ta4j-core/src/main/java/org/ta4j/core/num/BigDecimalNum.java","position":36,"original_position":36,"commit_id":"3c1a020e661155e58b1855f52cd1c7ffe45b1ab9","original_commit_id":"3c1a020e661155e58b1855f52cd1c7ffe45b1ab9","user":{"login":"edlins","id":12804882,"avatar_url":"https://avatars2.githubusercontent.com/u/12804882?v=4","gravatar_id":"","url":"https://api.github.com/users/edlins","html_url":"https://github.com/edlins","followers_url":"https://api.github.com/users/edlins/followers","following_url":"https://api.github.com/users/edlins/following{/other_user}","gists_url":"https://api.github.com/users/edlins/gists{/gist_id}","starred_url":"https://api.github.com/users/edlins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edlins/subscriptions","organizations_url":"https://api.github.com/users/edlins/orgs","repos_url":"https://api.github.com/users/edlins/repos","events_url":"https://api.github.com/users/edlins/events{/privacy}","received_events_url":"https://api.github.com/users/edlins/received_events","type":"User","site_admin":false},"body":"I re-wrote this as:\r\n```\r\n        BigDecimal power = (((BigDecimalNum) n).delegate);\r\n        BigDecimal remainderOf2 = power.remainder(BigDecimal.ONE);\r\n        BigDecimal n2IntPart = power.subtract(remainderOf2);\r\n        BigDecimal intPow = delegate.pow(n2IntPart.intValueExact(), MATH_CONTEXT);\r\n        BigDecimal doublePow = new BigDecimal(Math.pow(delegate.doubleValue(), remainderOf2.doubleValue()));\r\n        BigDecimal result = intPow.multiply(doublePow);\r\n        return new BigDecimalNum(result);\r\n```\r\nAnd got the same unit test results.","created_at":"2018-03-10T22:00:55Z","updated_at":"2018-03-10T22:03:16Z","html_url":"https://github.com/ta4j/ta4j/pull/212#discussion_r173636408","pull_request_url":"https://api.github.com/repos/ta4j/ta4j/pulls/212","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/ta4j/ta4j/pulls/comments/173636408"},"html":{"href":"https://github.com/ta4j/ta4j/pull/212#discussion_r173636408"},"pull_request":{"href":"https://api.github.com/repos/ta4j/ta4j/pulls/212"}}},"pull_request":{"url":"https://api.github.com/repos/ta4j/ta4j/pulls/212","id":173712901,"html_url":"https://github.com/ta4j/ta4j/pull/212","diff_url":"https://github.com/ta4j/ta4j/pull/212.diff","patch_url":"https://github.com/ta4j/ta4j/pull/212.patch","issue_url":"https://api.github.com/repos/ta4j/ta4j/issues/212","number":212,"state":"closed","locked":false,"title":"Add support for `Num.pow(Num)`","user":{"login":"MarijnKoesen","id":711208,"avatar_url":"https://avatars3.githubusercontent.com/u/711208?v=4","gravatar_id":"","url":"https://api.github.com/users/MarijnKoesen","html_url":"https://github.com/MarijnKoesen","followers_url":"https://api.github.com/users/MarijnKoesen/followers","following_url":"https://api.github.com/users/MarijnKoesen/following{/other_user}","gists_url":"https://api.github.com/users/MarijnKoesen/gists{/gist_id}","starred_url":"https://api.github.com/users/MarijnKoesen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MarijnKoesen/subscriptions","organizations_url":"https://api.github.com/users/MarijnKoesen/orgs","repos_url":"https://api.github.com/users/MarijnKoesen/repos","events_url":"https://api.github.com/users/MarijnKoesen/events{/privacy}","received_events_url":"https://api.github.com/users/MarijnKoesen/received_events","type":"User","site_admin":false},"body":"Fixes #.\r\n\r\nChanges proposed in this pull request:\r\n- Add support for `Num.pow(Num)`\r\n\r\n- [ ] added an entry to the unreleased section of `CHANGES.md` \r\n","created_at":"2018-03-08T11:34:14Z","updated_at":"2018-03-10T22:03:16Z","closed_at":"2018-03-10T09:50:22Z","merged_at":"2018-03-10T09:50:22Z","merge_commit_sha":"8149f7099f952ca65a29ff1243d9d28b493eb663","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/ta4j/ta4j/pulls/212/commits","review_comments_url":"https://api.github.com/repos/ta4j/ta4j/pulls/212/comments","review_comment_url":"https://api.github.com/repos/ta4j/ta4j/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ta4j/ta4j/issues/212/comments","statuses_url":"https://api.github.com/repos/ta4j/ta4j/statuses/3c1a020e661155e58b1855f52cd1c7ffe45b1ab9","head":{"label":"MarijnKoesen:feature/implement_num_pow_num","ref":"feature/implement_num_pow_num","sha":"3c1a020e661155e58b1855f52cd1c7ffe45b1ab9","user":{"login":"MarijnKoesen","id":711208,"avatar_url":"https://avatars3.githubusercontent.com/u/711208?v=4","gravatar_id":"","url":"https://api.github.com/users/MarijnKoesen","html_url":"https://github.com/MarijnKoesen","followers_url":"https://api.github.com/users/MarijnKoesen/followers","following_url":"https://api.github.com/users/MarijnKoesen/following{/other_user}","gists_url":"https://api.github.com/users/MarijnKoesen/gists{/gist_id}","starred_url":"https://api.github.com/users/MarijnKoesen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MarijnKoesen/subscriptions","organizations_url":"https://api.github.com/users/MarijnKoesen/orgs","repos_url":"https://api.github.com/users/MarijnKoesen/repos","events_url":"https://api.github.com/users/MarijnKoesen/events{/privacy}","received_events_url":"https://api.github.com/users/MarijnKoesen/received_events","type":"User","site_admin":false},"repo":{"id":123676914,"name":"ta4j","full_name":"MarijnKoesen/ta4j","owner":{"login":"MarijnKoesen","id":711208,"avatar_url":"https://avatars3.githubusercontent.com/u/711208?v=4","gravatar_id":"","url":"https://api.github.com/users/MarijnKoesen","html_url":"https://github.com/MarijnKoesen","followers_url":"https://api.github.com/users/MarijnKoesen/followers","following_url":"https://api.github.com/users/MarijnKoesen/following{/other_user}","gists_url":"https://api.github.com/users/MarijnKoesen/gists{/gist_id}","starred_url":"https://api.github.com/users/MarijnKoesen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MarijnKoesen/subscriptions","organizations_url":"https://api.github.com/users/MarijnKoesen/orgs","repos_url":"https://api.github.com/users/MarijnKoesen/repos","events_url":"https://api.github.com/users/MarijnKoesen/events{/privacy}","received_events_url":"https://api.github.com/users/MarijnKoesen/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/MarijnKoesen/ta4j","description":"A Java library for technical analysis.","fork":true,"url":"https://api.github.com/repos/MarijnKoesen/ta4j","forks_url":"https://api.github.com/repos/MarijnKoesen/ta4j/forks","keys_url":"https://api.github.com/repos/MarijnKoesen/ta4j/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MarijnKoesen/ta4j/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MarijnKoesen/ta4j/teams","hooks_url":"https://api.github.com/repos/MarijnKoesen/ta4j/hooks","issue_events_url":"https://api.github.com/repos/MarijnKoesen/ta4j/issues/events{/number}","events_url":"https://api.github.com/repos/MarijnKoesen/ta4j/events","assignees_url":"https://api.github.com/repos/MarijnKoesen/ta4j/assignees{/user}","branches_url":"https://api.github.com/repos/MarijnKoesen/ta4j/branches{/branch}","tags_url":"https://api.github.com/repos/MarijnKoesen/ta4j/tags","blobs_url":"https://api.github.com/repos/MarijnKoesen/ta4j/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MarijnKoesen/ta4j/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MarijnKoesen/ta4j/git/refs{/sha}","trees_url":"https://api.github.com/repos/MarijnKoesen/ta4j/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MarijnKoesen/ta4j/statuses/{sha}","languages_url":"https://api.github.com/repos/MarijnKoesen/ta4j/languages","stargazers_url":"https://api.github.com/repos/MarijnKoesen/ta4j/stargazers","contributors_url":"https://api.github.com/repos/MarijnKoesen/ta4j/contributors","subscribers_url":"https://api.github.com/repos/MarijnKoesen/ta4j/subscribers","subscription_url":"https://api.github.com/repos/MarijnKoesen/ta4j/subscription","commits_url":"https://api.github.com/repos/MarijnKoesen/ta4j/commits{/sha}","git_commits_url":"https://api.github.com/repos/MarijnKoesen/ta4j/git/commits{/sha}","comments_url":"https://api.github.com/repos/MarijnKoesen/ta4j/comments{/number}","issue_comment_url":"https://api.github.com/repos/MarijnKoesen/ta4j/issues/comments{/number}","contents_url":"https://api.github.com/repos/MarijnKoesen/ta4j/contents/{+path}","compare_url":"https://api.github.com/repos/MarijnKoesen/ta4j/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MarijnKoesen/ta4j/merges","archive_url":"https://api.github.com/repos/MarijnKoesen/ta4j/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MarijnKoesen/ta4j/downloads","issues_url":"https://api.github.com/repos/MarijnKoesen/ta4j/issues{/number}","pulls_url":"https://api.github.com/repos/MarijnKoesen/ta4j/pulls{/number}","milestones_url":"https://api.github.com/repos/MarijnKoesen/ta4j/milestones{/number}","notifications_url":"https://api.github.com/repos/MarijnKoesen/ta4j/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MarijnKoesen/ta4j/labels{/name}","releases_url":"https://api.github.com/repos/MarijnKoesen/ta4j/releases{/id}","deployments_url":"https://api.github.com/repos/MarijnKoesen/ta4j/deployments","created_at":"2018-03-03T09:15:45Z","updated_at":"2018-03-03T09:15:48Z","pushed_at":"2018-03-09T06:26:16Z","git_url":"git://github.com/MarijnKoesen/ta4j.git","ssh_url":"git@github.com:MarijnKoesen/ta4j.git","clone_url":"https://github.com/MarijnKoesen/ta4j.git","svn_url":"https://github.com/MarijnKoesen/ta4j","homepage":"https://ta4j.github.io/ta4j-wiki/","size":5028,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"ta4j:develop","ref":"develop","sha":"3e0ac2998d098b5be3acd199920e4fce6ba81796","user":{"login":"ta4j","id":31952695,"avatar_url":"https://avatars2.githubusercontent.com/u/31952695?v=4","gravatar_id":"","url":"https://api.github.com/users/ta4j","html_url":"https://github.com/ta4j","followers_url":"https://api.github.com/users/ta4j/followers","following_url":"https://api.github.com/users/ta4j/following{/other_user}","gists_url":"https://api.github.com/users/ta4j/gists{/gist_id}","starred_url":"https://api.github.com/users/ta4j/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ta4j/subscriptions","organizations_url":"https://api.github.com/users/ta4j/orgs","repos_url":"https://api.github.com/users/ta4j/repos","events_url":"https://api.github.com/users/ta4j/events{/privacy}","received_events_url":"https://api.github.com/users/ta4j/received_events","type":"Organization","site_admin":false},"repo":{"id":103560333,"name":"ta4j","full_name":"ta4j/ta4j","owner":{"login":"ta4j","id":31952695,"avatar_url":"https://avatars2.githubusercontent.com/u/31952695?v=4","gravatar_id":"","url":"https://api.github.com/users/ta4j","html_url":"https://github.com/ta4j","followers_url":"https://api.github.com/users/ta4j/followers","following_url":"https://api.github.com/users/ta4j/following{/other_user}","gists_url":"https://api.github.com/users/ta4j/gists{/gist_id}","starred_url":"https://api.github.com/users/ta4j/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ta4j/subscriptions","organizations_url":"https://api.github.com/users/ta4j/orgs","repos_url":"https://api.github.com/users/ta4j/repos","events_url":"https://api.github.com/users/ta4j/events{/privacy}","received_events_url":"https://api.github.com/users/ta4j/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ta4j/ta4j","description":"A Java library for technical analysis.","fork":false,"url":"https://api.github.com/repos/ta4j/ta4j","forks_url":"https://api.github.com/repos/ta4j/ta4j/forks","keys_url":"https://api.github.com/repos/ta4j/ta4j/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ta4j/ta4j/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ta4j/ta4j/teams","hooks_url":"https://api.github.com/repos/ta4j/ta4j/hooks","issue_events_url":"https://api.github.com/repos/ta4j/ta4j/issues/events{/number}","events_url":"https://api.github.com/repos/ta4j/ta4j/events","assignees_url":"https://api.github.com/repos/ta4j/ta4j/assignees{/user}","branches_url":"https://api.github.com/repos/ta4j/ta4j/branches{/branch}","tags_url":"https://api.github.com/repos/ta4j/ta4j/tags","blobs_url":"https://api.github.com/repos/ta4j/ta4j/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ta4j/ta4j/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ta4j/ta4j/git/refs{/sha}","trees_url":"https://api.github.com/repos/ta4j/ta4j/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ta4j/ta4j/statuses/{sha}","languages_url":"https://api.github.com/repos/ta4j/ta4j/languages","stargazers_url":"https://api.github.com/repos/ta4j/ta4j/stargazers","contributors_url":"https://api.github.com/repos/ta4j/ta4j/contributors","subscribers_url":"https://api.github.com/repos/ta4j/ta4j/subscribers","subscription_url":"https://api.github.com/repos/ta4j/ta4j/subscription","commits_url":"https://api.github.com/repos/ta4j/ta4j/commits{/sha}","git_commits_url":"https://api.github.com/repos/ta4j/ta4j/git/commits{/sha}","comments_url":"https://api.github.com/repos/ta4j/ta4j/comments{/number}","issue_comment_url":"https://api.github.com/repos/ta4j/ta4j/issues/comments{/number}","contents_url":"https://api.github.com/repos/ta4j/ta4j/contents/{+path}","compare_url":"https://api.github.com/repos/ta4j/ta4j/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ta4j/ta4j/merges","archive_url":"https://api.github.com/repos/ta4j/ta4j/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ta4j/ta4j/downloads","issues_url":"https://api.github.com/repos/ta4j/ta4j/issues{/number}","pulls_url":"https://api.github.com/repos/ta4j/ta4j/pulls{/number}","milestones_url":"https://api.github.com/repos/ta4j/ta4j/milestones{/number}","notifications_url":"https://api.github.com/repos/ta4j/ta4j/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ta4j/ta4j/labels{/name}","releases_url":"https://api.github.com/repos/ta4j/ta4j/releases{/id}","deployments_url":"https://api.github.com/repos/ta4j/ta4j/deployments","created_at":"2017-09-14T17:14:32Z","updated_at":"2018-03-10T17:20:54Z","pushed_at":"2018-03-10T10:41:51Z","git_url":"git://github.com/ta4j/ta4j.git","ssh_url":"git@github.com:ta4j/ta4j.git","clone_url":"https://github.com/ta4j/ta4j.git","svn_url":"https://github.com/ta4j/ta4j","homepage":"https://ta4j.github.io/ta4j-wiki/","size":5096,"stargazers_count":187,"watchers_count":187,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":74,"mirror_url":null,"archived":false,"open_issues_count":32,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":74,"open_issues":32,"watchers":187,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ta4j/ta4j/pulls/212"},"html":{"href":"https://github.com/ta4j/ta4j/pull/212"},"issue":{"href":"https://api.github.com/repos/ta4j/ta4j/issues/212"},"comments":{"href":"https://api.github.com/repos/ta4j/ta4j/issues/212/comments"},"review_comments":{"href":"https://api.github.com/repos/ta4j/ta4j/pulls/212/comments"},"review_comment":{"href":"https://api.github.com/repos/ta4j/ta4j/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ta4j/ta4j/pulls/212/commits"},"statuses":{"href":"https://api.github.com/repos/ta4j/ta4j/statuses/3c1a020e661155e58b1855f52cd1c7ffe45b1ab9"}},"author_association":"NONE"}}
{"actor":{"display_login":"edlins"}}