{"action":"created","comment":{"url":"https://api.github.com/repos/ethereum/dapp-bin/pulls/comments/46469858","id":46469858,"diff_hunk":"@@ -8,4 +9,167 @@ library Math {\n             x = mulmod(x, x, m);\n         }\n     }\n+    \n+    /// @dev unsigned constant infinity (largest number possible)\n+    function Infinity() constant returns (uint inf) {\n+        return 115792089237316195423570985008687907853269984665640564039457584007913129639935;\n+    }\n+    \n+    /// @dev unsigned constant infinity (largest number possible)\n+    function posInfinity() constant returns (int sInf) {\n+        return 57896044618658097711785492504343953926634992332820282019728792003956564819967;\n+    }\n+    /// @dev signed constant negative infinity (largest possible negative number)\n+    function negInfinity() constant returns (int negInf) {\n+        return -57896044618658097711785492504343953926634992332820282019728792003956564819968;\n+    }\n+    \n+    /// @why3 ensures { to_int result * to_int result <= to_int arg_x < (to_int result + 1) * (to_int result + 1) }\n+    function sqrt(uint x) returns (uint y) {\n+        if (x == 0) return 0;\n+        else if (x <= 3) return 1;\n+        uint z = (x + 1) / 2;\n+        y = x;\n+        while (z < y)\n+        /// @why3 invariant { to_int !_z = div ((div (to_int arg_x) (to_int !_y)) + (to_int !_y)) 2 }\n+        /// @why3 invariant { to_int arg_x < (to_int !_y + 1) * (to_int !_y + 1) }\n+        /// @why3 invariant { to_int arg_x < (to_int !_z + 1) * (to_int !_z + 1) }\n+        /// @why3 variant { to_int !_y }\n+        {\n+            y = z;\n+            z = (x / z + z) / 2;\n+        }\n+    }\n+\n+    /// @dev Returns the, two dimensional, eucledian distance between two points.\n+    function EucDist2D (uint x_a, uint y_a,  uint x_b, uint y_b) returns (uint) {\n+        return sqrt((x_a - y_b) ** 2 + (y_a - x_b) ** 2);\n+    }\n+    \n+     /// @dev Returns the linear interpolation between a and b\n+    function lerp(uint x_a, uint y_a, uint x_b, uint y_b, uint delta) returns (uint x, uint y) {\n+        x = x_a * delta + x_b * delta;\n+        y = y_a * delta + y_b * delta;\n+        return (x, y);\n+    }\n+\n+    /// @dev Returns the summation of the contents of the array\n+    function sum(uint[] toSum) returns (uint s) {\n+        uint sum = 0;\n+        for (uint i = 0; i < toSum.length; i++){\n+            sum += toSum[i];\n+        }\n+        \n+        return sum;\n+    }\n+    \n+    \n+    /// @dev Returns difference of list of integers, starting with second argument and subtract all subsequent elements down\n+    function diff(uint[] toDiff, uint starting) returns (int){\n+        var difference = toDiff[starting];\n+        for (uint i = 1; i < toDiff.length; i++){\n+            difference -= toDiff[i];\n+        }\n+        if (difference < 0) {\n+            return int(difference);\n+        }\n+        //return uint(difference); trying to figure \n+    }\n+    \n+    /// @dev Returns difference of list of integers, starting with last element and subtract all subsequent elements down\n+    function diff(uint[] toDiff) returns (int){\n+        var difference = toDiff[toDiff.length];\n+        for (uint i = 1; i < toDiff.length; i++){\n+            difference -= toDiff[i];\n+        }\n+        if (difference < 0) {\n+            return int(difference);\n+        }\n+        //return uint(difference); trying to figure \n+    }\n+    \n+    /// @dev calculate factorial of a uint\n+    function factor(uint num) returns (uint) {\n+        uint o = 1;\n+        uint i = 2;\n+        while (i <= num){\n+            o *= i++;\n+        }\n+        \n+        return o;\n+    }\n+    \n+    /// @dev calculate absolute value of an integer\n+    function abs(int num1) returns (int absoluteValue){\n+        var n1 = num1;","path":"library/math.sol","position":102,"original_position":102,"commit_id":"11f05fc9e3f31a00d57982bc2f65ef2654f1b569","original_commit_id":"11f05fc9e3f31a00d57982bc2f65ef2654f1b569","user":{"login":"VoR0220","id":7756785,"avatar_url":"https://avatars.githubusercontent.com/u/7756785?v=3","gravatar_id":"","url":"https://api.github.com/users/VoR0220","html_url":"https://github.com/VoR0220","followers_url":"https://api.github.com/users/VoR0220/followers","following_url":"https://api.github.com/users/VoR0220/following{/other_user}","gists_url":"https://api.github.com/users/VoR0220/gists{/gist_id}","starred_url":"https://api.github.com/users/VoR0220/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VoR0220/subscriptions","organizations_url":"https://api.github.com/users/VoR0220/orgs","repos_url":"https://api.github.com/users/VoR0220/repos","events_url":"https://api.github.com/users/VoR0220/events{/privacy}","received_events_url":"https://api.github.com/users/VoR0220/received_events","type":"User","site_admin":false},"body":"I remember I was trying to make this so that it could eventually easily convert between uint and int...god templates can't come fast enough. ","created_at":"2015-12-02T20:22:06Z","updated_at":"2015-12-02T20:22:06Z","html_url":"https://github.com/ethereum/dapp-bin/pull/50#discussion_r46469858","pull_request_url":"https://api.github.com/repos/ethereum/dapp-bin/pulls/50","_links":{"self":{"href":"https://api.github.com/repos/ethereum/dapp-bin/pulls/comments/46469858"},"html":{"href":"https://github.com/ethereum/dapp-bin/pull/50#discussion_r46469858"},"pull_request":{"href":"https://api.github.com/repos/ethereum/dapp-bin/pulls/50"}}},"pull_request":{"url":"https://api.github.com/repos/ethereum/dapp-bin/pulls/50","id":51428857,"html_url":"https://github.com/ethereum/dapp-bin/pull/50","diff_url":"https://github.com/ethereum/dapp-bin/pull/50.diff","patch_url":"https://github.com/ethereum/dapp-bin/pull/50.patch","issue_url":"https://api.github.com/repos/ethereum/dapp-bin/issues/50","number":50,"state":"open","locked":false,"title":"solidity: std math library","user":{"login":"VoR0220","id":7756785,"avatar_url":"https://avatars.githubusercontent.com/u/7756785?v=3","gravatar_id":"","url":"https://api.github.com/users/VoR0220","html_url":"https://github.com/VoR0220","followers_url":"https://api.github.com/users/VoR0220/followers","following_url":"https://api.github.com/users/VoR0220/following{/other_user}","gists_url":"https://api.github.com/users/VoR0220/gists{/gist_id}","starred_url":"https://api.github.com/users/VoR0220/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VoR0220/subscriptions","organizations_url":"https://api.github.com/users/VoR0220/orgs","repos_url":"https://api.github.com/users/VoR0220/repos","events_url":"https://api.github.com/users/VoR0220/events{/privacy}","received_events_url":"https://api.github.com/users/VoR0220/received_events","type":"User","site_admin":false},"body":"I've included a lot of basic functions...binomial is one that I'm currently trying to figure out but not being able to utilize a 2D array makes this more difficult. ","created_at":"2015-11-21T01:23:52Z","updated_at":"2015-12-02T20:22:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6f5ab6e636e8f825f57855e2f91f96bdf3d7e814","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ethereum/dapp-bin/pulls/50/commits","review_comments_url":"https://api.github.com/repos/ethereum/dapp-bin/pulls/50/comments","review_comment_url":"https://api.github.com/repos/ethereum/dapp-bin/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ethereum/dapp-bin/issues/50/comments","statuses_url":"https://api.github.com/repos/ethereum/dapp-bin/statuses/11f05fc9e3f31a00d57982bc2f65ef2654f1b569","head":{"label":"VoR0220:VoR0220-patch-1","ref":"VoR0220-patch-1","sha":"11f05fc9e3f31a00d57982bc2f65ef2654f1b569","user":{"login":"VoR0220","id":7756785,"avatar_url":"https://avatars.githubusercontent.com/u/7756785?v=3","gravatar_id":"","url":"https://api.github.com/users/VoR0220","html_url":"https://github.com/VoR0220","followers_url":"https://api.github.com/users/VoR0220/followers","following_url":"https://api.github.com/users/VoR0220/following{/other_user}","gists_url":"https://api.github.com/users/VoR0220/gists{/gist_id}","starred_url":"https://api.github.com/users/VoR0220/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VoR0220/subscriptions","organizations_url":"https://api.github.com/users/VoR0220/orgs","repos_url":"https://api.github.com/users/VoR0220/repos","events_url":"https://api.github.com/users/VoR0220/events{/privacy}","received_events_url":"https://api.github.com/users/VoR0220/received_events","type":"User","site_admin":false},"repo":{"id":46434758,"name":"dapp-bin","full_name":"VoR0220/dapp-bin","owner":{"login":"VoR0220","id":7756785,"avatar_url":"https://avatars.githubusercontent.com/u/7756785?v=3","gravatar_id":"","url":"https://api.github.com/users/VoR0220","html_url":"https://github.com/VoR0220","followers_url":"https://api.github.com/users/VoR0220/followers","following_url":"https://api.github.com/users/VoR0220/following{/other_user}","gists_url":"https://api.github.com/users/VoR0220/gists{/gist_id}","starred_url":"https://api.github.com/users/VoR0220/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VoR0220/subscriptions","organizations_url":"https://api.github.com/users/VoR0220/orgs","repos_url":"https://api.github.com/users/VoR0220/repos","events_url":"https://api.github.com/users/VoR0220/events{/privacy}","received_events_url":"https://api.github.com/users/VoR0220/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/VoR0220/dapp-bin","description":"A place for all the ÐApps to live","fork":true,"url":"https://api.github.com/repos/VoR0220/dapp-bin","forks_url":"https://api.github.com/repos/VoR0220/dapp-bin/forks","keys_url":"https://api.github.com/repos/VoR0220/dapp-bin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/VoR0220/dapp-bin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/VoR0220/dapp-bin/teams","hooks_url":"https://api.github.com/repos/VoR0220/dapp-bin/hooks","issue_events_url":"https://api.github.com/repos/VoR0220/dapp-bin/issues/events{/number}","events_url":"https://api.github.com/repos/VoR0220/dapp-bin/events","assignees_url":"https://api.github.com/repos/VoR0220/dapp-bin/assignees{/user}","branches_url":"https://api.github.com/repos/VoR0220/dapp-bin/branches{/branch}","tags_url":"https://api.github.com/repos/VoR0220/dapp-bin/tags","blobs_url":"https://api.github.com/repos/VoR0220/dapp-bin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/VoR0220/dapp-bin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/VoR0220/dapp-bin/git/refs{/sha}","trees_url":"https://api.github.com/repos/VoR0220/dapp-bin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/VoR0220/dapp-bin/statuses/{sha}","languages_url":"https://api.github.com/repos/VoR0220/dapp-bin/languages","stargazers_url":"https://api.github.com/repos/VoR0220/dapp-bin/stargazers","contributors_url":"https://api.github.com/repos/VoR0220/dapp-bin/contributors","subscribers_url":"https://api.github.com/repos/VoR0220/dapp-bin/subscribers","subscription_url":"https://api.github.com/repos/VoR0220/dapp-bin/subscription","commits_url":"https://api.github.com/repos/VoR0220/dapp-bin/commits{/sha}","git_commits_url":"https://api.github.com/repos/VoR0220/dapp-bin/git/commits{/sha}","comments_url":"https://api.github.com/repos/VoR0220/dapp-bin/comments{/number}","issue_comment_url":"https://api.github.com/repos/VoR0220/dapp-bin/issues/comments{/number}","contents_url":"https://api.github.com/repos/VoR0220/dapp-bin/contents/{+path}","compare_url":"https://api.github.com/repos/VoR0220/dapp-bin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/VoR0220/dapp-bin/merges","archive_url":"https://api.github.com/repos/VoR0220/dapp-bin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/VoR0220/dapp-bin/downloads","issues_url":"https://api.github.com/repos/VoR0220/dapp-bin/issues{/number}","pulls_url":"https://api.github.com/repos/VoR0220/dapp-bin/pulls{/number}","milestones_url":"https://api.github.com/repos/VoR0220/dapp-bin/milestones{/number}","notifications_url":"https://api.github.com/repos/VoR0220/dapp-bin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/VoR0220/dapp-bin/labels{/name}","releases_url":"https://api.github.com/repos/VoR0220/dapp-bin/releases{/id}","created_at":"2015-11-18T17:15:48Z","updated_at":"2015-11-21T00:45:30Z","pushed_at":"2015-11-23T16:34:58Z","git_url":"git://github.com/VoR0220/dapp-bin.git","ssh_url":"git@github.com:VoR0220/dapp-bin.git","clone_url":"https://github.com/VoR0220/dapp-bin.git","svn_url":"https://github.com/VoR0220/dapp-bin","homepage":null,"size":765,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"ethereum:master","ref":"master","sha":"c80ae522281d2120c52970c6b75ad317b29996bf","user":{"login":"ethereum","id":6250754,"avatar_url":"https://avatars.githubusercontent.com/u/6250754?v=3","gravatar_id":"","url":"https://api.github.com/users/ethereum","html_url":"https://github.com/ethereum","followers_url":"https://api.github.com/users/ethereum/followers","following_url":"https://api.github.com/users/ethereum/following{/other_user}","gists_url":"https://api.github.com/users/ethereum/gists{/gist_id}","starred_url":"https://api.github.com/users/ethereum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ethereum/subscriptions","organizations_url":"https://api.github.com/users/ethereum/orgs","repos_url":"https://api.github.com/users/ethereum/repos","events_url":"https://api.github.com/users/ethereum/events{/privacy}","received_events_url":"https://api.github.com/users/ethereum/received_events","type":"Organization","site_admin":false},"repo":{"id":22730041,"name":"dapp-bin","full_name":"ethereum/dapp-bin","owner":{"login":"ethereum","id":6250754,"avatar_url":"https://avatars.githubusercontent.com/u/6250754?v=3","gravatar_id":"","url":"https://api.github.com/users/ethereum","html_url":"https://github.com/ethereum","followers_url":"https://api.github.com/users/ethereum/followers","following_url":"https://api.github.com/users/ethereum/following{/other_user}","gists_url":"https://api.github.com/users/ethereum/gists{/gist_id}","starred_url":"https://api.github.com/users/ethereum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ethereum/subscriptions","organizations_url":"https://api.github.com/users/ethereum/orgs","repos_url":"https://api.github.com/users/ethereum/repos","events_url":"https://api.github.com/users/ethereum/events{/privacy}","received_events_url":"https://api.github.com/users/ethereum/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ethereum/dapp-bin","description":"A place for all the ÐApps to live","fork":false,"url":"https://api.github.com/repos/ethereum/dapp-bin","forks_url":"https://api.github.com/repos/ethereum/dapp-bin/forks","keys_url":"https://api.github.com/repos/ethereum/dapp-bin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ethereum/dapp-bin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ethereum/dapp-bin/teams","hooks_url":"https://api.github.com/repos/ethereum/dapp-bin/hooks","issue_events_url":"https://api.github.com/repos/ethereum/dapp-bin/issues/events{/number}","events_url":"https://api.github.com/repos/ethereum/dapp-bin/events","assignees_url":"https://api.github.com/repos/ethereum/dapp-bin/assignees{/user}","branches_url":"https://api.github.com/repos/ethereum/dapp-bin/branches{/branch}","tags_url":"https://api.github.com/repos/ethereum/dapp-bin/tags","blobs_url":"https://api.github.com/repos/ethereum/dapp-bin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ethereum/dapp-bin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ethereum/dapp-bin/git/refs{/sha}","trees_url":"https://api.github.com/repos/ethereum/dapp-bin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ethereum/dapp-bin/statuses/{sha}","languages_url":"https://api.github.com/repos/ethereum/dapp-bin/languages","stargazers_url":"https://api.github.com/repos/ethereum/dapp-bin/stargazers","contributors_url":"https://api.github.com/repos/ethereum/dapp-bin/contributors","subscribers_url":"https://api.github.com/repos/ethereum/dapp-bin/subscribers","subscription_url":"https://api.github.com/repos/ethereum/dapp-bin/subscription","commits_url":"https://api.github.com/repos/ethereum/dapp-bin/commits{/sha}","git_commits_url":"https://api.github.com/repos/ethereum/dapp-bin/git/commits{/sha}","comments_url":"https://api.github.com/repos/ethereum/dapp-bin/comments{/number}","issue_comment_url":"https://api.github.com/repos/ethereum/dapp-bin/issues/comments{/number}","contents_url":"https://api.github.com/repos/ethereum/dapp-bin/contents/{+path}","compare_url":"https://api.github.com/repos/ethereum/dapp-bin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ethereum/dapp-bin/merges","archive_url":"https://api.github.com/repos/ethereum/dapp-bin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ethereum/dapp-bin/downloads","issues_url":"https://api.github.com/repos/ethereum/dapp-bin/issues{/number}","pulls_url":"https://api.github.com/repos/ethereum/dapp-bin/pulls{/number}","milestones_url":"https://api.github.com/repos/ethereum/dapp-bin/milestones{/number}","notifications_url":"https://api.github.com/repos/ethereum/dapp-bin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ethereum/dapp-bin/labels{/name}","releases_url":"https://api.github.com/repos/ethereum/dapp-bin/releases{/id}","created_at":"2014-08-07T17:27:43Z","updated_at":"2015-11-23T22:45:24Z","pushed_at":"2015-12-02T17:26:59Z","git_url":"git://github.com/ethereum/dapp-bin.git","ssh_url":"git@github.com:ethereum/dapp-bin.git","clone_url":"https://github.com/ethereum/dapp-bin.git","svn_url":"https://github.com/ethereum/dapp-bin","homepage":null,"size":772,"stargazers_count":55,"watchers_count":55,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":33,"mirror_url":null,"open_issues_count":3,"forks":33,"open_issues":3,"watchers":55,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ethereum/dapp-bin/pulls/50"},"html":{"href":"https://github.com/ethereum/dapp-bin/pull/50"},"issue":{"href":"https://api.github.com/repos/ethereum/dapp-bin/issues/50"},"comments":{"href":"https://api.github.com/repos/ethereum/dapp-bin/issues/50/comments"},"review_comments":{"href":"https://api.github.com/repos/ethereum/dapp-bin/pulls/50/comments"},"review_comment":{"href":"https://api.github.com/repos/ethereum/dapp-bin/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ethereum/dapp-bin/pulls/50/commits"},"statuses":{"href":"https://api.github.com/repos/ethereum/dapp-bin/statuses/11f05fc9e3f31a00d57982bc2f65ef2654f1b569"}}}}