{"action":"created","issue":{"url":"https://api.github.com/repos/alexei/sprintf.js/issues/103","repository_url":"https://api.github.com/repos/alexei/sprintf.js","labels_url":"https://api.github.com/repos/alexei/sprintf.js/issues/103/labels{/name}","comments_url":"https://api.github.com/repos/alexei/sprintf.js/issues/103/comments","events_url":"https://api.github.com/repos/alexei/sprintf.js/issues/103/events","html_url":"https://github.com/alexei/sprintf.js/issues/103","id":142055915,"number":103,"title":"Integer printing error for small numbers","user":{"login":"axfree","id":329456,"avatar_url":"https://avatars.githubusercontent.com/u/329456?v=3","gravatar_id":"","url":"https://api.github.com/users/axfree","html_url":"https://github.com/axfree","followers_url":"https://api.github.com/users/axfree/followers","following_url":"https://api.github.com/users/axfree/following{/other_user}","gists_url":"https://api.github.com/users/axfree/gists{/gist_id}","starred_url":"https://api.github.com/users/axfree/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/axfree/subscriptions","organizations_url":"https://api.github.com/users/axfree/orgs","repos_url":"https://api.github.com/users/axfree/repos","events_url":"https://api.github.com/users/axfree/events{/privacy}","received_events_url":"https://api.github.com/users/axfree/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-03-19T12:09:27Z","updated_at":"2016-11-08T19:16:17Z","closed_at":null,"body":"If the number is floating point number and its exponent is in certain range, sprintf prints wrong number.\n\n``` javascript\nvar a = 9.9999e-7;\n\nconsole.log(a);\n// ==> 9.9999e-7\n\nconsole.log(sprintf('%d', a));\n// ==> 9 (0 expected)\n\nconsole.log(sprintf('%d', a + 0.0001));\n// ==> 0\n\nconsole.log(sprintf('%d', a.toFixed()));\n// ==> 0\n\nconsole.log(parseInt(a));\n// ==> 9\n\nconsole.log(parseInt(a.toFixed()));\n// ==> 0\n\n```\n\nTo fix this, if the type specifier is integer (/bcdiuxX/), arg must first be converted to the fixed point number using toFixed().\ntoFixed() also does the rounding which is also desired.\n"},"comment":{"url":"https://api.github.com/repos/alexei/sprintf.js/issues/comments/259231329","html_url":"https://github.com/alexei/sprintf.js/issues/103#issuecomment-259231329","issue_url":"https://api.github.com/repos/alexei/sprintf.js/issues/103","id":259231329,"user":{"login":"rustafaria","id":23342623,"avatar_url":"https://avatars.githubusercontent.com/u/23342623?v=3","gravatar_id":"","url":"https://api.github.com/users/rustafaria","html_url":"https://github.com/rustafaria","followers_url":"https://api.github.com/users/rustafaria/followers","following_url":"https://api.github.com/users/rustafaria/following{/other_user}","gists_url":"https://api.github.com/users/rustafaria/gists{/gist_id}","starred_url":"https://api.github.com/users/rustafaria/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rustafaria/subscriptions","organizations_url":"https://api.github.com/users/rustafaria/orgs","repos_url":"https://api.github.com/users/rustafaria/repos","events_url":"https://api.github.com/users/rustafaria/events{/privacy}","received_events_url":"https://api.github.com/users/rustafaria/received_events","type":"User","site_admin":false},"created_at":"2016-11-08T19:16:17Z","updated_at":"2016-11-08T19:16:17Z","body":"sprintf isn't doing the right thing when the toString is printed as exponential.  exp <= -7 and exp >= 21 cause this problem"}}
{"actor":{"display_login":"rustafaria"}}