{"action":"created","comment":{"url":"https://api.github.com/repos/0xProject/contracts/pulls/comments/130033522","pull_request_review_id":52866599,"id":130033522,"diff_hunk":"@@ -76,4 +77,56 @@ contract('Exchange', (accounts: string[]) => {\n       assert(!success);\n     });\n   });\n+\n+  describe('isRoundingError', () => {\n+    it('should return true if there is a rounding error > 0.1%', async () => {\n+      const numerator = new BigNumber(3);\n+      const denominator = new BigNumber(7);\n+      const target = new BigNumber(10);\n+      // rounding error = ((3*10/7) - floor(3*10/7)) / (3*10/7) = 6.67%\n+      const isRoundingError = await exWrapper.isRoundingErrorAsync(numerator, denominator, target);\n+      assert.equal(isRoundingError, true);\n+    });\n+\n+    it('should return false when there is no rounding error', async () => {\n+      const numerator = new BigNumber(1);\n+      const denominator = new BigNumber(2);\n+      const target = new BigNumber(10);\n+\n+      const isRoundingError = await exWrapper.isRoundingErrorAsync(numerator, denominator, target);\n+      assert.equal(isRoundingError, false);\n+    });\n+\n+    it('should return false when there is rounding error <= 0.1%', async () => {\n+      // randomly generated numbers\n+      const numerator = new BigNumber(76564);\n+      const denominator = new BigNumber(676373677);\n+      const target = new BigNumber(105762562);\n+      // rounding error = ((76564*105762562/676373677) - floor(76564*105762562/676373677)) / (76564*105762562/676373677) = 0.0007%\n+      const isRoundingError = await exWrapper.isRoundingErrorAsync(numerator, denominator, target);\n+      assert.equal(isRoundingError, false);\n+    });\n+  });\n+\n+  describe('getPartialAmount', () => {\n+    it('should return the numerator/denominator*target', async () => {\n+      const numerator = new BigNumber(1);\n+      const denominator = new BigNumber(2);\n+      const target = new BigNumber(10);\n+\n+      const partialAmount = await exWrapper.getPartialAmountAsync(numerator, denominator, target);\n+      const expectedPartialAmount = '5';\n+      assert.equal(partialAmount.toString(), expectedPartialAmount);\n+    });\n+\n+    it('should round down', async () => {\n+      const numerator = new BigNumber(2);\n+      const denominator = new BigNumber(3);\n+      const target = new BigNumber(10);\n+\n+      const partialAmount = await exWrapper.getPartialAmountAsync(numerator, denominator, target);\n+      const expectedPartialAmount = '6';\n+      assert.equal(partialAmount.toString(), expectedPartialAmount);\n+    });\n+  });","path":"test/ts/exchange/helpers.ts","position":61,"original_position":61,"commit_id":"e7c291037d5f1f12be6410dc37c5abbf2de8d9a3","original_commit_id":"e7c291037d5f1f12be6410dc37c5abbf2de8d9a3","user":{"login":"LogvinovLeon","id":6204356,"avatar_url":"https://avatars1.githubusercontent.com/u/6204356?v=4","gravatar_id":"","url":"https://api.github.com/users/LogvinovLeon","html_url":"https://github.com/LogvinovLeon","followers_url":"https://api.github.com/users/LogvinovLeon/followers","following_url":"https://api.github.com/users/LogvinovLeon/following{/other_user}","gists_url":"https://api.github.com/users/LogvinovLeon/gists{/gist_id}","starred_url":"https://api.github.com/users/LogvinovLeon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LogvinovLeon/subscriptions","organizations_url":"https://api.github.com/users/LogvinovLeon/orgs","repos_url":"https://api.github.com/users/LogvinovLeon/repos","events_url":"https://api.github.com/users/LogvinovLeon/events{/privacy}","received_events_url":"https://api.github.com/users/LogvinovLeon/received_events","type":"User","site_admin":false},"body":"I'll add one more test for rounding of 0.5. Different implementations differ and we want to make sure it's behaving like expected.\r\n```\r\nconst numerator = new BigNumber(1);\r\nconst denominator = new BigNumber(20);\r\nconst target = new BigNumber(10);\r\n```","created_at":"2017-07-28T08:01:07Z","updated_at":"2017-07-28T08:17:26Z","html_url":"https://github.com/0xProject/contracts/pull/129#discussion_r130033522","pull_request_url":"https://api.github.com/repos/0xProject/contracts/pulls/129","_links":{"self":{"href":"https://api.github.com/repos/0xProject/contracts/pulls/comments/130033522"},"html":{"href":"https://github.com/0xProject/contracts/pull/129#discussion_r130033522"},"pull_request":{"href":"https://api.github.com/repos/0xProject/contracts/pulls/129"}}},"pull_request":{"url":"https://api.github.com/repos/0xProject/contracts/pulls/129","id":132912853,"html_url":"https://github.com/0xProject/contracts/pull/129","diff_url":"https://github.com/0xProject/contracts/pull/129.diff","patch_url":"https://github.com/0xProject/contracts/pull/129.patch","issue_url":"https://api.github.com/repos/0xProject/contracts/issues/129","number":129,"state":"open","locked":false,"title":"Fix isRoundingError","user":{"login":"abandeali1","id":18060168,"avatar_url":"https://avatars0.githubusercontent.com/u/18060168?v=4","gravatar_id":"","url":"https://api.github.com/users/abandeali1","html_url":"https://github.com/abandeali1","followers_url":"https://api.github.com/users/abandeali1/followers","following_url":"https://api.github.com/users/abandeali1/following{/other_user}","gists_url":"https://api.github.com/users/abandeali1/gists{/gist_id}","starred_url":"https://api.github.com/users/abandeali1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abandeali1/subscriptions","organizations_url":"https://api.github.com/users/abandeali1/orgs","repos_url":"https://api.github.com/users/abandeali1/repos","events_url":"https://api.github.com/users/abandeali1/events{/privacy}","received_events_url":"https://api.github.com/users/abandeali1/received_events","type":"User","site_admin":false},"body":"- Closes issues #98 and #92","created_at":"2017-07-28T07:47:47Z","updated_at":"2017-07-28T08:17:26Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8199f9827a41b49a854a9649015b3d8f86aab586","assignee":null,"assignees":[],"requested_reviewers":[{"login":"fabioberger","id":2151492,"avatar_url":"https://avatars2.githubusercontent.com/u/2151492?v=4","gravatar_id":"","url":"https://api.github.com/users/fabioberger","html_url":"https://github.com/fabioberger","followers_url":"https://api.github.com/users/fabioberger/followers","following_url":"https://api.github.com/users/fabioberger/following{/other_user}","gists_url":"https://api.github.com/users/fabioberger/gists{/gist_id}","starred_url":"https://api.github.com/users/fabioberger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fabioberger/subscriptions","organizations_url":"https://api.github.com/users/fabioberger/orgs","repos_url":"https://api.github.com/users/fabioberger/repos","events_url":"https://api.github.com/users/fabioberger/events{/privacy}","received_events_url":"https://api.github.com/users/fabioberger/received_events","type":"User","site_admin":false},{"login":"willwarren89","id":2459070,"avatar_url":"https://avatars0.githubusercontent.com/u/2459070?v=4","gravatar_id":"","url":"https://api.github.com/users/willwarren89","html_url":"https://github.com/willwarren89","followers_url":"https://api.github.com/users/willwarren89/followers","following_url":"https://api.github.com/users/willwarren89/following{/other_user}","gists_url":"https://api.github.com/users/willwarren89/gists{/gist_id}","starred_url":"https://api.github.com/users/willwarren89/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/willwarren89/subscriptions","organizations_url":"https://api.github.com/users/willwarren89/orgs","repos_url":"https://api.github.com/users/willwarren89/repos","events_url":"https://api.github.com/users/willwarren89/events{/privacy}","received_events_url":"https://api.github.com/users/willwarren89/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/0xProject/contracts/pulls/129/commits","review_comments_url":"https://api.github.com/repos/0xProject/contracts/pulls/129/comments","review_comment_url":"https://api.github.com/repos/0xProject/contracts/pulls/comments{/number}","comments_url":"https://api.github.com/repos/0xProject/contracts/issues/129/comments","statuses_url":"https://api.github.com/repos/0xProject/contracts/statuses/e7c291037d5f1f12be6410dc37c5abbf2de8d9a3","head":{"label":"0xProject:roundingError","ref":"roundingError","sha":"e7c291037d5f1f12be6410dc37c5abbf2de8d9a3","user":{"login":"0xProject","id":24832717,"avatar_url":"https://avatars2.githubusercontent.com/u/24832717?v=4","gravatar_id":"","url":"https://api.github.com/users/0xProject","html_url":"https://github.com/0xProject","followers_url":"https://api.github.com/users/0xProject/followers","following_url":"https://api.github.com/users/0xProject/following{/other_user}","gists_url":"https://api.github.com/users/0xProject/gists{/gist_id}","starred_url":"https://api.github.com/users/0xProject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/0xProject/subscriptions","organizations_url":"https://api.github.com/users/0xProject/orgs","repos_url":"https://api.github.com/users/0xProject/repos","events_url":"https://api.github.com/users/0xProject/events{/privacy}","received_events_url":"https://api.github.com/users/0xProject/received_events","type":"Organization","site_admin":false},"repo":{"id":80661110,"name":"contracts","full_name":"0xProject/contracts","owner":{"login":"0xProject","id":24832717,"avatar_url":"https://avatars2.githubusercontent.com/u/24832717?v=4","gravatar_id":"","url":"https://api.github.com/users/0xProject","html_url":"https://github.com/0xProject","followers_url":"https://api.github.com/users/0xProject/followers","following_url":"https://api.github.com/users/0xProject/following{/other_user}","gists_url":"https://api.github.com/users/0xProject/gists{/gist_id}","starred_url":"https://api.github.com/users/0xProject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/0xProject/subscriptions","organizations_url":"https://api.github.com/users/0xProject/orgs","repos_url":"https://api.github.com/users/0xProject/repos","events_url":"https://api.github.com/users/0xProject/events{/privacy}","received_events_url":"https://api.github.com/users/0xProject/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/0xProject/contracts","description":"0x smart contracts and tests.","fork":false,"url":"https://api.github.com/repos/0xProject/contracts","forks_url":"https://api.github.com/repos/0xProject/contracts/forks","keys_url":"https://api.github.com/repos/0xProject/contracts/keys{/key_id}","collaborators_url":"https://api.github.com/repos/0xProject/contracts/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/0xProject/contracts/teams","hooks_url":"https://api.github.com/repos/0xProject/contracts/hooks","issue_events_url":"https://api.github.com/repos/0xProject/contracts/issues/events{/number}","events_url":"https://api.github.com/repos/0xProject/contracts/events","assignees_url":"https://api.github.com/repos/0xProject/contracts/assignees{/user}","branches_url":"https://api.github.com/repos/0xProject/contracts/branches{/branch}","tags_url":"https://api.github.com/repos/0xProject/contracts/tags","blobs_url":"https://api.github.com/repos/0xProject/contracts/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/0xProject/contracts/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/0xProject/contracts/git/refs{/sha}","trees_url":"https://api.github.com/repos/0xProject/contracts/git/trees{/sha}","statuses_url":"https://api.github.com/repos/0xProject/contracts/statuses/{sha}","languages_url":"https://api.github.com/repos/0xProject/contracts/languages","stargazers_url":"https://api.github.com/repos/0xProject/contracts/stargazers","contributors_url":"https://api.github.com/repos/0xProject/contracts/contributors","subscribers_url":"https://api.github.com/repos/0xProject/contracts/subscribers","subscription_url":"https://api.github.com/repos/0xProject/contracts/subscription","commits_url":"https://api.github.com/repos/0xProject/contracts/commits{/sha}","git_commits_url":"https://api.github.com/repos/0xProject/contracts/git/commits{/sha}","comments_url":"https://api.github.com/repos/0xProject/contracts/comments{/number}","issue_comment_url":"https://api.github.com/repos/0xProject/contracts/issues/comments{/number}","contents_url":"https://api.github.com/repos/0xProject/contracts/contents/{+path}","compare_url":"https://api.github.com/repos/0xProject/contracts/compare/{base}...{head}","merges_url":"https://api.github.com/repos/0xProject/contracts/merges","archive_url":"https://api.github.com/repos/0xProject/contracts/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/0xProject/contracts/downloads","issues_url":"https://api.github.com/repos/0xProject/contracts/issues{/number}","pulls_url":"https://api.github.com/repos/0xProject/contracts/pulls{/number}","milestones_url":"https://api.github.com/repos/0xProject/contracts/milestones{/number}","notifications_url":"https://api.github.com/repos/0xProject/contracts/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/0xProject/contracts/labels{/name}","releases_url":"https://api.github.com/repos/0xProject/contracts/releases{/id}","deployments_url":"https://api.github.com/repos/0xProject/contracts/deployments","created_at":"2017-02-01T20:31:07Z","updated_at":"2017-07-26T05:02:14Z","pushed_at":"2017-07-28T07:47:47Z","git_url":"git://github.com/0xProject/contracts.git","ssh_url":"git@github.com:0xProject/contracts.git","clone_url":"https://github.com/0xProject/contracts.git","svn_url":"https://github.com/0xProject/contracts","homepage":"","size":2472,"stargazers_count":80,"watchers_count":80,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":18,"mirror_url":null,"open_issues_count":12,"forks":18,"open_issues":12,"watchers":80,"default_branch":"master"}},"base":{"label":"0xProject:frozenUpdated","ref":"frozenUpdated","sha":"35a959e9865bf089de96f510bb8bd1aa33d67e68","user":{"login":"0xProject","id":24832717,"avatar_url":"https://avatars2.githubusercontent.com/u/24832717?v=4","gravatar_id":"","url":"https://api.github.com/users/0xProject","html_url":"https://github.com/0xProject","followers_url":"https://api.github.com/users/0xProject/followers","following_url":"https://api.github.com/users/0xProject/following{/other_user}","gists_url":"https://api.github.com/users/0xProject/gists{/gist_id}","starred_url":"https://api.github.com/users/0xProject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/0xProject/subscriptions","organizations_url":"https://api.github.com/users/0xProject/orgs","repos_url":"https://api.github.com/users/0xProject/repos","events_url":"https://api.github.com/users/0xProject/events{/privacy}","received_events_url":"https://api.github.com/users/0xProject/received_events","type":"Organization","site_admin":false},"repo":{"id":80661110,"name":"contracts","full_name":"0xProject/contracts","owner":{"login":"0xProject","id":24832717,"avatar_url":"https://avatars2.githubusercontent.com/u/24832717?v=4","gravatar_id":"","url":"https://api.github.com/users/0xProject","html_url":"https://github.com/0xProject","followers_url":"https://api.github.com/users/0xProject/followers","following_url":"https://api.github.com/users/0xProject/following{/other_user}","gists_url":"https://api.github.com/users/0xProject/gists{/gist_id}","starred_url":"https://api.github.com/users/0xProject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/0xProject/subscriptions","organizations_url":"https://api.github.com/users/0xProject/orgs","repos_url":"https://api.github.com/users/0xProject/repos","events_url":"https://api.github.com/users/0xProject/events{/privacy}","received_events_url":"https://api.github.com/users/0xProject/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/0xProject/contracts","description":"0x smart contracts and tests.","fork":false,"url":"https://api.github.com/repos/0xProject/contracts","forks_url":"https://api.github.com/repos/0xProject/contracts/forks","keys_url":"https://api.github.com/repos/0xProject/contracts/keys{/key_id}","collaborators_url":"https://api.github.com/repos/0xProject/contracts/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/0xProject/contracts/teams","hooks_url":"https://api.github.com/repos/0xProject/contracts/hooks","issue_events_url":"https://api.github.com/repos/0xProject/contracts/issues/events{/number}","events_url":"https://api.github.com/repos/0xProject/contracts/events","assignees_url":"https://api.github.com/repos/0xProject/contracts/assignees{/user}","branches_url":"https://api.github.com/repos/0xProject/contracts/branches{/branch}","tags_url":"https://api.github.com/repos/0xProject/contracts/tags","blobs_url":"https://api.github.com/repos/0xProject/contracts/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/0xProject/contracts/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/0xProject/contracts/git/refs{/sha}","trees_url":"https://api.github.com/repos/0xProject/contracts/git/trees{/sha}","statuses_url":"https://api.github.com/repos/0xProject/contracts/statuses/{sha}","languages_url":"https://api.github.com/repos/0xProject/contracts/languages","stargazers_url":"https://api.github.com/repos/0xProject/contracts/stargazers","contributors_url":"https://api.github.com/repos/0xProject/contracts/contributors","subscribers_url":"https://api.github.com/repos/0xProject/contracts/subscribers","subscription_url":"https://api.github.com/repos/0xProject/contracts/subscription","commits_url":"https://api.github.com/repos/0xProject/contracts/commits{/sha}","git_commits_url":"https://api.github.com/repos/0xProject/contracts/git/commits{/sha}","comments_url":"https://api.github.com/repos/0xProject/contracts/comments{/number}","issue_comment_url":"https://api.github.com/repos/0xProject/contracts/issues/comments{/number}","contents_url":"https://api.github.com/repos/0xProject/contracts/contents/{+path}","compare_url":"https://api.github.com/repos/0xProject/contracts/compare/{base}...{head}","merges_url":"https://api.github.com/repos/0xProject/contracts/merges","archive_url":"https://api.github.com/repos/0xProject/contracts/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/0xProject/contracts/downloads","issues_url":"https://api.github.com/repos/0xProject/contracts/issues{/number}","pulls_url":"https://api.github.com/repos/0xProject/contracts/pulls{/number}","milestones_url":"https://api.github.com/repos/0xProject/contracts/milestones{/number}","notifications_url":"https://api.github.com/repos/0xProject/contracts/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/0xProject/contracts/labels{/name}","releases_url":"https://api.github.com/repos/0xProject/contracts/releases{/id}","deployments_url":"https://api.github.com/repos/0xProject/contracts/deployments","created_at":"2017-02-01T20:31:07Z","updated_at":"2017-07-26T05:02:14Z","pushed_at":"2017-07-28T07:47:47Z","git_url":"git://github.com/0xProject/contracts.git","ssh_url":"git@github.com:0xProject/contracts.git","clone_url":"https://github.com/0xProject/contracts.git","svn_url":"https://github.com/0xProject/contracts","homepage":"","size":2472,"stargazers_count":80,"watchers_count":80,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":18,"mirror_url":null,"open_issues_count":12,"forks":18,"open_issues":12,"watchers":80,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/0xProject/contracts/pulls/129"},"html":{"href":"https://github.com/0xProject/contracts/pull/129"},"issue":{"href":"https://api.github.com/repos/0xProject/contracts/issues/129"},"comments":{"href":"https://api.github.com/repos/0xProject/contracts/issues/129/comments"},"review_comments":{"href":"https://api.github.com/repos/0xProject/contracts/pulls/129/comments"},"review_comment":{"href":"https://api.github.com/repos/0xProject/contracts/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/0xProject/contracts/pulls/129/commits"},"statuses":{"href":"https://api.github.com/repos/0xProject/contracts/statuses/e7c291037d5f1f12be6410dc37c5abbf2de8d9a3"}}}}
{"actor":{"display_login":"LogvinovLeon"}}