{"action":"created","comment":{"url":"https://api.github.com/repos/RIOT-OS/RIOT/pulls/comments/108418998","pull_request_review_id":29447252,"id":108418998,"diff_hunk":"@@ -243,6 +243,56 @@ size_t fmt_s16_dfp(char *out, int16_t val, unsigned fp_digits)\n     return pos;\n }\n \n+static const uint32_t _tenmap[] = {\n+    0,\n+    10LU,\n+    100LU,\n+    1000LU,\n+    10000LU,\n+    100000LU,\n+    1000000LU,\n+    10000000LU,\n+};\n+\n+/* this is very probably not the most efficient implementation, as it at least\n+ * pulls in floating point math.  But it works, and it's always nice to have\n+ * low hanging fruits when optimizing. (Kaspar)\n+ */\n+size_t fmt_float(char *out, float f, unsigned precision)\n+{\n+    assert (precision <= 7);\n+\n+    unsigned negative = (f < 0);\n+    uint32_t integer;\n+\n+    if (negative) {\n+        f *= -1;\n+    }\n+\n+    integer = (uint32_t) f;\n+    f -= integer;\n+\n+    uint32_t fraction = f * _tenmap[precision];\n+\n+    size_t res = negative;\n+    if (negative && out) {\n+        *out++ = '-';\n+    }\n+\n+    res += fmt_u32_dec(out, integer);\n+    if (precision && fraction) {\n+        if (out) {\n+            out += res;\n+            *out++ = '.';\n+            size_t tmp = fmt_u32_dec(out, fraction);\n+            fmt_lpad(out, tmp, precision, '0');\n+        }\n+        res += (1 + precision);","path":"sys/fmt/fmt.c","position":48,"original_position":48,"commit_id":"013f4217257ec1ee6f54f8f493b21f4b5318340c","original_commit_id":"013f4217257ec1ee6f54f8f493b21f4b5318340c","user":{"login":"lebrush","id":1437538,"avatar_url":"https://avatars2.githubusercontent.com/u/1437538?v=3","gravatar_id":"","url":"https://api.github.com/users/lebrush","html_url":"https://github.com/lebrush","followers_url":"https://api.github.com/users/lebrush/followers","following_url":"https://api.github.com/users/lebrush/following{/other_user}","gists_url":"https://api.github.com/users/lebrush/gists{/gist_id}","starred_url":"https://api.github.com/users/lebrush/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lebrush/subscriptions","organizations_url":"https://api.github.com/users/lebrush/orgs","repos_url":"https://api.github.com/users/lebrush/repos","events_url":"https://api.github.com/users/lebrush/events{/privacy}","received_events_url":"https://api.github.com/users/lebrush/received_events","type":"User","site_admin":false},"body":"- `res` shouldn't be incremented except it has been really outputted, right? Because the docu says \"number of characters actually written\"\r\n- Actually `fmt_u32_dec` returns 1 even if `out == NULL` and no characters are written... Documentation should also be updated there.\r\n- `fmt_lpad` doesn't test that `out is not NULL` if `FMT_USE_MEMMOVE == 0` (not sure otherwise, depends on implementation I guess).","created_at":"2017-03-28T13:24:11Z","updated_at":"2017-03-28T13:48:40Z","html_url":"https://github.com/RIOT-OS/RIOT/pull/6800#discussion_r108418998","pull_request_url":"https://api.github.com/repos/RIOT-OS/RIOT/pulls/6800","_links":{"self":{"href":"https://api.github.com/repos/RIOT-OS/RIOT/pulls/comments/108418998"},"html":{"href":"https://github.com/RIOT-OS/RIOT/pull/6800#discussion_r108418998"},"pull_request":{"href":"https://api.github.com/repos/RIOT-OS/RIOT/pulls/6800"}}},"pull_request":{"url":"https://api.github.com/repos/RIOT-OS/RIOT/pulls/6800","id":112846336,"html_url":"https://github.com/RIOT-OS/RIOT/pull/6800","diff_url":"https://github.com/RIOT-OS/RIOT/pull/6800.diff","patch_url":"https://github.com/RIOT-OS/RIOT/pull/6800.patch","issue_url":"https://api.github.com/repos/RIOT-OS/RIOT/issues/6800","number":6800,"state":"open","locked":false,"title":"sys: fmt: add fmt_float() and print_float()","user":{"login":"kaspar030","id":4679640,"avatar_url":"https://avatars3.githubusercontent.com/u/4679640?v=3","gravatar_id":"","url":"https://api.github.com/users/kaspar030","html_url":"https://github.com/kaspar030","followers_url":"https://api.github.com/users/kaspar030/followers","following_url":"https://api.github.com/users/kaspar030/following{/other_user}","gists_url":"https://api.github.com/users/kaspar030/gists{/gist_id}","starred_url":"https://api.github.com/users/kaspar030/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kaspar030/subscriptions","organizations_url":"https://api.github.com/users/kaspar030/orgs","repos_url":"https://api.github.com/users/kaspar030/repos","events_url":"https://api.github.com/users/kaspar030/events{/privacy}","received_events_url":"https://api.github.com/users/kaspar030/received_events","type":"User","site_admin":false},"body":"This PR adds crude float formatting / printing ability to fmt.\r\n\r\nThis does, when used, add 2.4k of float code dependencies. On the other hand, our current default toolchain doesn't include float printf capability.\r\n\r\nAlso, this only adds overhead when actually used.","created_at":"2017-03-27T21:47:54Z","updated_at":"2017-03-28T13:48:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"39c99ae43184e53f0071e5248cb021358c135c29","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/RIOT-OS/RIOT/pulls/6800/commits","review_comments_url":"https://api.github.com/repos/RIOT-OS/RIOT/pulls/6800/comments","review_comment_url":"https://api.github.com/repos/RIOT-OS/RIOT/pulls/comments{/number}","comments_url":"https://api.github.com/repos/RIOT-OS/RIOT/issues/6800/comments","statuses_url":"https://api.github.com/repos/RIOT-OS/RIOT/statuses/013f4217257ec1ee6f54f8f493b21f4b5318340c","head":{"label":"kaspar030:add_fmt_float","ref":"add_fmt_float","sha":"013f4217257ec1ee6f54f8f493b21f4b5318340c","user":{"login":"kaspar030","id":4679640,"avatar_url":"https://avatars3.githubusercontent.com/u/4679640?v=3","gravatar_id":"","url":"https://api.github.com/users/kaspar030","html_url":"https://github.com/kaspar030","followers_url":"https://api.github.com/users/kaspar030/followers","following_url":"https://api.github.com/users/kaspar030/following{/other_user}","gists_url":"https://api.github.com/users/kaspar030/gists{/gist_id}","starred_url":"https://api.github.com/users/kaspar030/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kaspar030/subscriptions","organizations_url":"https://api.github.com/users/kaspar030/orgs","repos_url":"https://api.github.com/users/kaspar030/repos","events_url":"https://api.github.com/users/kaspar030/events{/privacy}","received_events_url":"https://api.github.com/users/kaspar030/received_events","type":"User","site_admin":false},"repo":{"id":14115364,"name":"RIOT","full_name":"kaspar030/RIOT","owner":{"login":"kaspar030","id":4679640,"avatar_url":"https://avatars3.githubusercontent.com/u/4679640?v=3","gravatar_id":"","url":"https://api.github.com/users/kaspar030","html_url":"https://github.com/kaspar030","followers_url":"https://api.github.com/users/kaspar030/followers","following_url":"https://api.github.com/users/kaspar030/following{/other_user}","gists_url":"https://api.github.com/users/kaspar030/gists{/gist_id}","starred_url":"https://api.github.com/users/kaspar030/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kaspar030/subscriptions","organizations_url":"https://api.github.com/users/kaspar030/orgs","repos_url":"https://api.github.com/users/kaspar030/repos","events_url":"https://api.github.com/users/kaspar030/events{/privacy}","received_events_url":"https://api.github.com/users/kaspar030/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kaspar030/RIOT","description":"RIOT -  The friendly OS for IoT","fork":true,"url":"https://api.github.com/repos/kaspar030/RIOT","forks_url":"https://api.github.com/repos/kaspar030/RIOT/forks","keys_url":"https://api.github.com/repos/kaspar030/RIOT/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kaspar030/RIOT/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kaspar030/RIOT/teams","hooks_url":"https://api.github.com/repos/kaspar030/RIOT/hooks","issue_events_url":"https://api.github.com/repos/kaspar030/RIOT/issues/events{/number}","events_url":"https://api.github.com/repos/kaspar030/RIOT/events","assignees_url":"https://api.github.com/repos/kaspar030/RIOT/assignees{/user}","branches_url":"https://api.github.com/repos/kaspar030/RIOT/branches{/branch}","tags_url":"https://api.github.com/repos/kaspar030/RIOT/tags","blobs_url":"https://api.github.com/repos/kaspar030/RIOT/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kaspar030/RIOT/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kaspar030/RIOT/git/refs{/sha}","trees_url":"https://api.github.com/repos/kaspar030/RIOT/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kaspar030/RIOT/statuses/{sha}","languages_url":"https://api.github.com/repos/kaspar030/RIOT/languages","stargazers_url":"https://api.github.com/repos/kaspar030/RIOT/stargazers","contributors_url":"https://api.github.com/repos/kaspar030/RIOT/contributors","subscribers_url":"https://api.github.com/repos/kaspar030/RIOT/subscribers","subscription_url":"https://api.github.com/repos/kaspar030/RIOT/subscription","commits_url":"https://api.github.com/repos/kaspar030/RIOT/commits{/sha}","git_commits_url":"https://api.github.com/repos/kaspar030/RIOT/git/commits{/sha}","comments_url":"https://api.github.com/repos/kaspar030/RIOT/comments{/number}","issue_comment_url":"https://api.github.com/repos/kaspar030/RIOT/issues/comments{/number}","contents_url":"https://api.github.com/repos/kaspar030/RIOT/contents/{+path}","compare_url":"https://api.github.com/repos/kaspar030/RIOT/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kaspar030/RIOT/merges","archive_url":"https://api.github.com/repos/kaspar030/RIOT/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kaspar030/RIOT/downloads","issues_url":"https://api.github.com/repos/kaspar030/RIOT/issues{/number}","pulls_url":"https://api.github.com/repos/kaspar030/RIOT/pulls{/number}","milestones_url":"https://api.github.com/repos/kaspar030/RIOT/milestones{/number}","notifications_url":"https://api.github.com/repos/kaspar030/RIOT/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kaspar030/RIOT/labels{/name}","releases_url":"https://api.github.com/repos/kaspar030/RIOT/releases{/id}","deployments_url":"https://api.github.com/repos/kaspar030/RIOT/deployments","created_at":"2013-11-04T16:04:12Z","updated_at":"2015-05-08T14:32:24Z","pushed_at":"2017-03-27T21:44:25Z","git_url":"git://github.com/kaspar030/RIOT.git","ssh_url":"git@github.com:kaspar030/RIOT.git","clone_url":"https://github.com/kaspar030/RIOT.git","svn_url":"https://github.com/kaspar030/RIOT","homepage":"https://github.com/RIOT-OS/RIOT/wiki","size":36845,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":6,"forks":0,"open_issues":6,"watchers":0,"default_branch":"master"}},"base":{"label":"RIOT-OS:master","ref":"master","sha":"796eb64c0bed4246827b82cd1a15436c9699f539","user":{"login":"RIOT-OS","id":3079480,"avatar_url":"https://avatars1.githubusercontent.com/u/3079480?v=3","gravatar_id":"","url":"https://api.github.com/users/RIOT-OS","html_url":"https://github.com/RIOT-OS","followers_url":"https://api.github.com/users/RIOT-OS/followers","following_url":"https://api.github.com/users/RIOT-OS/following{/other_user}","gists_url":"https://api.github.com/users/RIOT-OS/gists{/gist_id}","starred_url":"https://api.github.com/users/RIOT-OS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RIOT-OS/subscriptions","organizations_url":"https://api.github.com/users/RIOT-OS/orgs","repos_url":"https://api.github.com/users/RIOT-OS/repos","events_url":"https://api.github.com/users/RIOT-OS/events{/privacy}","received_events_url":"https://api.github.com/users/RIOT-OS/received_events","type":"Organization","site_admin":false},"repo":{"id":7370241,"name":"RIOT","full_name":"RIOT-OS/RIOT","owner":{"login":"RIOT-OS","id":3079480,"avatar_url":"https://avatars1.githubusercontent.com/u/3079480?v=3","gravatar_id":"","url":"https://api.github.com/users/RIOT-OS","html_url":"https://github.com/RIOT-OS","followers_url":"https://api.github.com/users/RIOT-OS/followers","following_url":"https://api.github.com/users/RIOT-OS/following{/other_user}","gists_url":"https://api.github.com/users/RIOT-OS/gists{/gist_id}","starred_url":"https://api.github.com/users/RIOT-OS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RIOT-OS/subscriptions","organizations_url":"https://api.github.com/users/RIOT-OS/orgs","repos_url":"https://api.github.com/users/RIOT-OS/repos","events_url":"https://api.github.com/users/RIOT-OS/events{/privacy}","received_events_url":"https://api.github.com/users/RIOT-OS/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/RIOT-OS/RIOT","description":"RIOT -  The friendly OS for IoT","fork":false,"url":"https://api.github.com/repos/RIOT-OS/RIOT","forks_url":"https://api.github.com/repos/RIOT-OS/RIOT/forks","keys_url":"https://api.github.com/repos/RIOT-OS/RIOT/keys{/key_id}","collaborators_url":"https://api.github.com/repos/RIOT-OS/RIOT/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/RIOT-OS/RIOT/teams","hooks_url":"https://api.github.com/repos/RIOT-OS/RIOT/hooks","issue_events_url":"https://api.github.com/repos/RIOT-OS/RIOT/issues/events{/number}","events_url":"https://api.github.com/repos/RIOT-OS/RIOT/events","assignees_url":"https://api.github.com/repos/RIOT-OS/RIOT/assignees{/user}","branches_url":"https://api.github.com/repos/RIOT-OS/RIOT/branches{/branch}","tags_url":"https://api.github.com/repos/RIOT-OS/RIOT/tags","blobs_url":"https://api.github.com/repos/RIOT-OS/RIOT/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/RIOT-OS/RIOT/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/RIOT-OS/RIOT/git/refs{/sha}","trees_url":"https://api.github.com/repos/RIOT-OS/RIOT/git/trees{/sha}","statuses_url":"https://api.github.com/repos/RIOT-OS/RIOT/statuses/{sha}","languages_url":"https://api.github.com/repos/RIOT-OS/RIOT/languages","stargazers_url":"https://api.github.com/repos/RIOT-OS/RIOT/stargazers","contributors_url":"https://api.github.com/repos/RIOT-OS/RIOT/contributors","subscribers_url":"https://api.github.com/repos/RIOT-OS/RIOT/subscribers","subscription_url":"https://api.github.com/repos/RIOT-OS/RIOT/subscription","commits_url":"https://api.github.com/repos/RIOT-OS/RIOT/commits{/sha}","git_commits_url":"https://api.github.com/repos/RIOT-OS/RIOT/git/commits{/sha}","comments_url":"https://api.github.com/repos/RIOT-OS/RIOT/comments{/number}","issue_comment_url":"https://api.github.com/repos/RIOT-OS/RIOT/issues/comments{/number}","contents_url":"https://api.github.com/repos/RIOT-OS/RIOT/contents/{+path}","compare_url":"https://api.github.com/repos/RIOT-OS/RIOT/compare/{base}...{head}","merges_url":"https://api.github.com/repos/RIOT-OS/RIOT/merges","archive_url":"https://api.github.com/repos/RIOT-OS/RIOT/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/RIOT-OS/RIOT/downloads","issues_url":"https://api.github.com/repos/RIOT-OS/RIOT/issues{/number}","pulls_url":"https://api.github.com/repos/RIOT-OS/RIOT/pulls{/number}","milestones_url":"https://api.github.com/repos/RIOT-OS/RIOT/milestones{/number}","notifications_url":"https://api.github.com/repos/RIOT-OS/RIOT/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/RIOT-OS/RIOT/labels{/name}","releases_url":"https://api.github.com/repos/RIOT-OS/RIOT/releases{/id}","deployments_url":"https://api.github.com/repos/RIOT-OS/RIOT/deployments","created_at":"2012-12-29T20:38:40Z","updated_at":"2017-03-28T09:31:41Z","pushed_at":"2017-03-28T13:42:28Z","git_url":"git://github.com/RIOT-OS/RIOT.git","ssh_url":"git@github.com:RIOT-OS/RIOT.git","clone_url":"https://github.com/RIOT-OS/RIOT.git","svn_url":"https://github.com/RIOT-OS/RIOT","homepage":"https://github.com/RIOT-OS/RIOT/wiki","size":36459,"stargazers_count":1192,"watchers_count":1192,"language":"C","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":737,"mirror_url":null,"open_issues_count":554,"forks":737,"open_issues":554,"watchers":1192,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/RIOT-OS/RIOT/pulls/6800"},"html":{"href":"https://github.com/RIOT-OS/RIOT/pull/6800"},"issue":{"href":"https://api.github.com/repos/RIOT-OS/RIOT/issues/6800"},"comments":{"href":"https://api.github.com/repos/RIOT-OS/RIOT/issues/6800/comments"},"review_comments":{"href":"https://api.github.com/repos/RIOT-OS/RIOT/pulls/6800/comments"},"review_comment":{"href":"https://api.github.com/repos/RIOT-OS/RIOT/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/RIOT-OS/RIOT/pulls/6800/commits"},"statuses":{"href":"https://api.github.com/repos/RIOT-OS/RIOT/statuses/013f4217257ec1ee6f54f8f493b21f4b5318340c"}}}}
{"actor":{"display_login":"lebrush"}}