{"action":"created","comment":{"url":"https://api.github.com/repos/angular/angular.js/pulls/comments/46325660","id":46325660,"diff_hunk":"@@ -139,93 +141,186 @@ function numberFilter($locale) {\n   };\n }\n \n-var DECIMAL_SEP = '.';\n-function formatNumber(number, pattern, groupSep, decimalSep, fractionSize) {\n-  if (isObject(number)) return '';\n+/**\n+ * parse a number (as a string) into three components that can be used\n+ * for formatting the number\n+ * @param  {string} numStr The number to parse\n+ * @return {object} An object describing this number, containing the following keys:\n+ *  - d : an array of digits containing leading zeros as necessary\n+ *  - i : the number of the digits in `d` that are to the left of the decimal point\n+ *  - e : the exponent for numbers that would need more than `MAX_DIGITS` digits in `d`\n+ *\n+ */\n+function parse(numStr) {\n+  var exponent = 0, digits, integerLen;\n+  var e, i, j, zeros;\n+\n+  // Decimal point?\n+  if ((e = numStr.indexOf(DECIMAL_SEP)) > -1) {\n+    numStr = numStr.replace(DECIMAL_SEP, '');\n+  }\n+  // Exponential form?\n+  if ((i = numStr.search(/e/i)) > 0) {\n+    // Determine exponent.\n+    if (e < 0) e = i;\n+    e += +numStr.slice(i + 1);\n+    numStr = numStr.substring(0, i);\n+  } else if (e < 0) {\n+    // Integer.\n+    e = numStr.length;\n+  }\n+  // Determine leading zeros.\n+  for (i = 0; numStr.charAt(i) == ZERO_CHAR; i++);\n \n-  var isNegative = number < 0;\n-  number = Math.abs(number);\n+  if (i == (zeros = numStr.length)) {\n+    // Zero.\n+    digits = [0];\n+    integerLen = 1;\n+  } else {\n+    // Determine trailing zeros.\n+    while (numStr.charAt(--zeros) == ZERO_CHAR);\n+    integerLen = e - i;\n+    digits = [];\n+    // Convert string to array of digits without leading/trailing zeros.\n+    for (j = 0; i <= zeros; i++, j++) {\n+      digits[j] = +numStr.charAt(i);\n+    }\n+  }\n+\n+  // if the overflow the maximum allowed digits then use an exponent","path":"src/ng/filter/filters.js","position":74,"original_position":74,"commit_id":"42731c3e6e506ff95636ba554958479b8e39733c","original_commit_id":"42731c3e6e506ff95636ba554958479b8e39733c","user":{"login":"Narretz","id":1153097,"avatar_url":"https://avatars.githubusercontent.com/u/1153097?v=3","gravatar_id":"","url":"https://api.github.com/users/Narretz","html_url":"https://github.com/Narretz","followers_url":"https://api.github.com/users/Narretz/followers","following_url":"https://api.github.com/users/Narretz/following{/other_user}","gists_url":"https://api.github.com/users/Narretz/gists{/gist_id}","starred_url":"https://api.github.com/users/Narretz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Narretz/subscriptions","organizations_url":"https://api.github.com/users/Narretz/orgs","repos_url":"https://api.github.com/users/Narretz/repos","events_url":"https://api.github.com/users/Narretz/events{/privacy}","received_events_url":"https://api.github.com/users/Narretz/received_events","type":"User","site_admin":false},"body":"Can this be reworded? I think there's a word missing or one too many","created_at":"2015-12-01T19:28:03Z","updated_at":"2015-12-01T19:28:03Z","html_url":"https://github.com/angular/angular.js/pull/13394#discussion_r46325660","pull_request_url":"https://api.github.com/repos/angular/angular.js/pulls/13394","_links":{"self":{"href":"https://api.github.com/repos/angular/angular.js/pulls/comments/46325660"},"html":{"href":"https://github.com/angular/angular.js/pull/13394#discussion_r46325660"},"pull_request":{"href":"https://api.github.com/repos/angular/angular.js/pulls/13394"}}},"pull_request":{"url":"https://api.github.com/repos/angular/angular.js/pulls/13394","id":51990860,"html_url":"https://github.com/angular/angular.js/pull/13394","diff_url":"https://github.com/angular/angular.js/pull/13394.diff","patch_url":"https://github.com/angular/angular.js/pull/13394.patch","issue_url":"https://api.github.com/repos/angular/angular.js/issues/13394","number":13394,"state":"open","locked":false,"title":"fix(formatNumber): better corner case handling","user":{"login":"petebacondarwin","id":15655,"avatar_url":"https://avatars.githubusercontent.com/u/15655?v=3","gravatar_id":"","url":"https://api.github.com/users/petebacondarwin","html_url":"https://github.com/petebacondarwin","followers_url":"https://api.github.com/users/petebacondarwin/followers","following_url":"https://api.github.com/users/petebacondarwin/following{/other_user}","gists_url":"https://api.github.com/users/petebacondarwin/gists{/gist_id}","starred_url":"https://api.github.com/users/petebacondarwin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/petebacondarwin/subscriptions","organizations_url":"https://api.github.com/users/petebacondarwin/orgs","repos_url":"https://api.github.com/users/petebacondarwin/repos","events_url":"https://api.github.com/users/petebacondarwin/events{/privacy}","received_events_url":"https://api.github.com/users/petebacondarwin/received_events","type":"User","site_admin":false},"body":"The idea here is that we actually parse the input number ourselves and then do the rounding ourselves manually. This allows us more control and reliability on the output for corner case numbers.\r\n\r\nCloses #8674\r\nCloses #12709 \r\nCloses #8705 \r\nCloses #12707 \r\nCloses #10246\r\nCloses #10252","created_at":"2015-11-27T12:38:16Z","updated_at":"2015-12-01T19:28:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bd23f71fe2b8ea0503d4c231efa0fdfe2ed726d8","assignee":null,"milestone":{"url":"https://api.github.com/repos/angular/angular.js/milestones/110","html_url":"https://github.com/angular/angular.js/milestones/1.4.9","labels_url":"https://api.github.com/repos/angular/angular.js/milestones/110/labels","id":1431117,"number":110,"title":"1.4.9","description":"","creator":{"login":"Narretz","id":1153097,"avatar_url":"https://avatars.githubusercontent.com/u/1153097?v=3","gravatar_id":"","url":"https://api.github.com/users/Narretz","html_url":"https://github.com/Narretz","followers_url":"https://api.github.com/users/Narretz/followers","following_url":"https://api.github.com/users/Narretz/following{/other_user}","gists_url":"https://api.github.com/users/Narretz/gists{/gist_id}","starred_url":"https://api.github.com/users/Narretz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Narretz/subscriptions","organizations_url":"https://api.github.com/users/Narretz/orgs","repos_url":"https://api.github.com/users/Narretz/repos","events_url":"https://api.github.com/users/Narretz/events{/privacy}","received_events_url":"https://api.github.com/users/Narretz/received_events","type":"User","site_admin":false},"open_issues":30,"closed_issues":1,"state":"open","created_at":"2015-11-26T12:57:33Z","updated_at":"2015-12-01T19:17:08Z","due_on":"2015-12-02T23:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/angular/angular.js/pulls/13394/commits","review_comments_url":"https://api.github.com/repos/angular/angular.js/pulls/13394/comments","review_comment_url":"https://api.github.com/repos/angular/angular.js/pulls/comments{/number}","comments_url":"https://api.github.com/repos/angular/angular.js/issues/13394/comments","statuses_url":"https://api.github.com/repos/angular/angular.js/statuses/42731c3e6e506ff95636ba554958479b8e39733c","head":{"label":"petebacondarwin:formatNumberFixes","ref":"formatNumberFixes","sha":"42731c3e6e506ff95636ba554958479b8e39733c","user":{"login":"petebacondarwin","id":15655,"avatar_url":"https://avatars.githubusercontent.com/u/15655?v=3","gravatar_id":"","url":"https://api.github.com/users/petebacondarwin","html_url":"https://github.com/petebacondarwin","followers_url":"https://api.github.com/users/petebacondarwin/followers","following_url":"https://api.github.com/users/petebacondarwin/following{/other_user}","gists_url":"https://api.github.com/users/petebacondarwin/gists{/gist_id}","starred_url":"https://api.github.com/users/petebacondarwin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/petebacondarwin/subscriptions","organizations_url":"https://api.github.com/users/petebacondarwin/orgs","repos_url":"https://api.github.com/users/petebacondarwin/repos","events_url":"https://api.github.com/users/petebacondarwin/events{/privacy}","received_events_url":"https://api.github.com/users/petebacondarwin/received_events","type":"User","site_admin":false},"repo":{"id":6367749,"name":"angular.js","full_name":"petebacondarwin/angular.js","owner":{"login":"petebacondarwin","id":15655,"avatar_url":"https://avatars.githubusercontent.com/u/15655?v=3","gravatar_id":"","url":"https://api.github.com/users/petebacondarwin","html_url":"https://github.com/petebacondarwin","followers_url":"https://api.github.com/users/petebacondarwin/followers","following_url":"https://api.github.com/users/petebacondarwin/following{/other_user}","gists_url":"https://api.github.com/users/petebacondarwin/gists{/gist_id}","starred_url":"https://api.github.com/users/petebacondarwin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/petebacondarwin/subscriptions","organizations_url":"https://api.github.com/users/petebacondarwin/orgs","repos_url":"https://api.github.com/users/petebacondarwin/repos","events_url":"https://api.github.com/users/petebacondarwin/events{/privacy}","received_events_url":"https://api.github.com/users/petebacondarwin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/petebacondarwin/angular.js","description":"","fork":true,"url":"https://api.github.com/repos/petebacondarwin/angular.js","forks_url":"https://api.github.com/repos/petebacondarwin/angular.js/forks","keys_url":"https://api.github.com/repos/petebacondarwin/angular.js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/petebacondarwin/angular.js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/petebacondarwin/angular.js/teams","hooks_url":"https://api.github.com/repos/petebacondarwin/angular.js/hooks","issue_events_url":"https://api.github.com/repos/petebacondarwin/angular.js/issues/events{/number}","events_url":"https://api.github.com/repos/petebacondarwin/angular.js/events","assignees_url":"https://api.github.com/repos/petebacondarwin/angular.js/assignees{/user}","branches_url":"https://api.github.com/repos/petebacondarwin/angular.js/branches{/branch}","tags_url":"https://api.github.com/repos/petebacondarwin/angular.js/tags","blobs_url":"https://api.github.com/repos/petebacondarwin/angular.js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/petebacondarwin/angular.js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/petebacondarwin/angular.js/git/refs{/sha}","trees_url":"https://api.github.com/repos/petebacondarwin/angular.js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/petebacondarwin/angular.js/statuses/{sha}","languages_url":"https://api.github.com/repos/petebacondarwin/angular.js/languages","stargazers_url":"https://api.github.com/repos/petebacondarwin/angular.js/stargazers","contributors_url":"https://api.github.com/repos/petebacondarwin/angular.js/contributors","subscribers_url":"https://api.github.com/repos/petebacondarwin/angular.js/subscribers","subscription_url":"https://api.github.com/repos/petebacondarwin/angular.js/subscription","commits_url":"https://api.github.com/repos/petebacondarwin/angular.js/commits{/sha}","git_commits_url":"https://api.github.com/repos/petebacondarwin/angular.js/git/commits{/sha}","comments_url":"https://api.github.com/repos/petebacondarwin/angular.js/comments{/number}","issue_comment_url":"https://api.github.com/repos/petebacondarwin/angular.js/issues/comments{/number}","contents_url":"https://api.github.com/repos/petebacondarwin/angular.js/contents/{+path}","compare_url":"https://api.github.com/repos/petebacondarwin/angular.js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/petebacondarwin/angular.js/merges","archive_url":"https://api.github.com/repos/petebacondarwin/angular.js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/petebacondarwin/angular.js/downloads","issues_url":"https://api.github.com/repos/petebacondarwin/angular.js/issues{/number}","pulls_url":"https://api.github.com/repos/petebacondarwin/angular.js/pulls{/number}","milestones_url":"https://api.github.com/repos/petebacondarwin/angular.js/milestones{/number}","notifications_url":"https://api.github.com/repos/petebacondarwin/angular.js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/petebacondarwin/angular.js/labels{/name}","releases_url":"https://api.github.com/repos/petebacondarwin/angular.js/releases{/id}","created_at":"2012-10-24T09:47:23Z","updated_at":"2015-05-19T08:10:36Z","pushed_at":"2015-12-01T11:17:51Z","git_url":"git://github.com/petebacondarwin/angular.js.git","ssh_url":"git@github.com:petebacondarwin/angular.js.git","clone_url":"https://github.com/petebacondarwin/angular.js.git","svn_url":"https://github.com/petebacondarwin/angular.js","homepage":"http://angularjs.org","size":80148,"stargazers_count":3,"watchers_count":3,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":3,"default_branch":"master"}},"base":{"label":"angular:master","ref":"master","sha":"73e38658c4e7414d862fc487e75908890a1e6237","user":{"login":"angular","id":139426,"avatar_url":"https://avatars.githubusercontent.com/u/139426?v=3","gravatar_id":"","url":"https://api.github.com/users/angular","html_url":"https://github.com/angular","followers_url":"https://api.github.com/users/angular/followers","following_url":"https://api.github.com/users/angular/following{/other_user}","gists_url":"https://api.github.com/users/angular/gists{/gist_id}","starred_url":"https://api.github.com/users/angular/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/angular/subscriptions","organizations_url":"https://api.github.com/users/angular/orgs","repos_url":"https://api.github.com/users/angular/repos","events_url":"https://api.github.com/users/angular/events{/privacy}","received_events_url":"https://api.github.com/users/angular/received_events","type":"Organization","site_admin":false},"repo":{"id":460078,"name":"angular.js","full_name":"angular/angular.js","owner":{"login":"angular","id":139426,"avatar_url":"https://avatars.githubusercontent.com/u/139426?v=3","gravatar_id":"","url":"https://api.github.com/users/angular","html_url":"https://github.com/angular","followers_url":"https://api.github.com/users/angular/followers","following_url":"https://api.github.com/users/angular/following{/other_user}","gists_url":"https://api.github.com/users/angular/gists{/gist_id}","starred_url":"https://api.github.com/users/angular/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/angular/subscriptions","organizations_url":"https://api.github.com/users/angular/orgs","repos_url":"https://api.github.com/users/angular/repos","events_url":"https://api.github.com/users/angular/events{/privacy}","received_events_url":"https://api.github.com/users/angular/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/angular/angular.js","description":"HTML enhanced for web apps","fork":false,"url":"https://api.github.com/repos/angular/angular.js","forks_url":"https://api.github.com/repos/angular/angular.js/forks","keys_url":"https://api.github.com/repos/angular/angular.js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/angular/angular.js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/angular/angular.js/teams","hooks_url":"https://api.github.com/repos/angular/angular.js/hooks","issue_events_url":"https://api.github.com/repos/angular/angular.js/issues/events{/number}","events_url":"https://api.github.com/repos/angular/angular.js/events","assignees_url":"https://api.github.com/repos/angular/angular.js/assignees{/user}","branches_url":"https://api.github.com/repos/angular/angular.js/branches{/branch}","tags_url":"https://api.github.com/repos/angular/angular.js/tags","blobs_url":"https://api.github.com/repos/angular/angular.js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/angular/angular.js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/angular/angular.js/git/refs{/sha}","trees_url":"https://api.github.com/repos/angular/angular.js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/angular/angular.js/statuses/{sha}","languages_url":"https://api.github.com/repos/angular/angular.js/languages","stargazers_url":"https://api.github.com/repos/angular/angular.js/stargazers","contributors_url":"https://api.github.com/repos/angular/angular.js/contributors","subscribers_url":"https://api.github.com/repos/angular/angular.js/subscribers","subscription_url":"https://api.github.com/repos/angular/angular.js/subscription","commits_url":"https://api.github.com/repos/angular/angular.js/commits{/sha}","git_commits_url":"https://api.github.com/repos/angular/angular.js/git/commits{/sha}","comments_url":"https://api.github.com/repos/angular/angular.js/comments{/number}","issue_comment_url":"https://api.github.com/repos/angular/angular.js/issues/comments{/number}","contents_url":"https://api.github.com/repos/angular/angular.js/contents/{+path}","compare_url":"https://api.github.com/repos/angular/angular.js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/angular/angular.js/merges","archive_url":"https://api.github.com/repos/angular/angular.js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/angular/angular.js/downloads","issues_url":"https://api.github.com/repos/angular/angular.js/issues{/number}","pulls_url":"https://api.github.com/repos/angular/angular.js/pulls{/number}","milestones_url":"https://api.github.com/repos/angular/angular.js/milestones{/number}","notifications_url":"https://api.github.com/repos/angular/angular.js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/angular/angular.js/labels{/name}","releases_url":"https://api.github.com/repos/angular/angular.js/releases{/id}","created_at":"2010-01-06T00:34:37Z","updated_at":"2015-12-01T19:10:55Z","pushed_at":"2015-12-01T19:15:04Z","git_url":"git://github.com/angular/angular.js.git","ssh_url":"git@github.com:angular/angular.js.git","clone_url":"https://github.com/angular/angular.js.git","svn_url":"https://github.com/angular/angular.js","homepage":"http://angularjs.org","size":140418,"stargazers_count":44718,"watchers_count":44718,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":20504,"mirror_url":null,"open_issues_count":1255,"forks":20504,"open_issues":1255,"watchers":44718,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/angular/angular.js/pulls/13394"},"html":{"href":"https://github.com/angular/angular.js/pull/13394"},"issue":{"href":"https://api.github.com/repos/angular/angular.js/issues/13394"},"comments":{"href":"https://api.github.com/repos/angular/angular.js/issues/13394/comments"},"review_comments":{"href":"https://api.github.com/repos/angular/angular.js/pulls/13394/comments"},"review_comment":{"href":"https://api.github.com/repos/angular/angular.js/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/angular/angular.js/pulls/13394/commits"},"statuses":{"href":"https://api.github.com/repos/angular/angular.js/statuses/42731c3e6e506ff95636ba554958479b8e39733c"}}}}