{"action":"created","issue":{"url":"https://api.github.com/repos/adamwdraper/Numeral-js/issues/194","labels_url":"https://api.github.com/repos/adamwdraper/Numeral-js/issues/194/labels{/name}","comments_url":"https://api.github.com/repos/adamwdraper/Numeral-js/issues/194/comments","events_url":"https://api.github.com/repos/adamwdraper/Numeral-js/issues/194/events","html_url":"https://github.com/adamwdraper/Numeral-js/issues/194","id":38138413,"number":194,"title":"Specifying a number of significant digits?","user":{"login":"rickhuizinga","id":3828214,"avatar_url":"https://avatars.githubusercontent.com/u/3828214?v=3","gravatar_id":"","url":"https://api.github.com/users/rickhuizinga","html_url":"https://github.com/rickhuizinga","followers_url":"https://api.github.com/users/rickhuizinga/followers","following_url":"https://api.github.com/users/rickhuizinga/following{/other_user}","gists_url":"https://api.github.com/users/rickhuizinga/gists{/gist_id}","starred_url":"https://api.github.com/users/rickhuizinga/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rickhuizinga/subscriptions","organizations_url":"https://api.github.com/users/rickhuizinga/orgs","repos_url":"https://api.github.com/users/rickhuizinga/repos","events_url":"https://api.github.com/users/rickhuizinga/events{/privacy}","received_events_url":"https://api.github.com/users/rickhuizinga/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2014-07-18T00:14:18Z","updated_at":"2015-04-27T17:49:31Z","closed_at":null,"body":"First, this has been a very handy library.\r\n\r\nI would like to limit the number of significant digits to 3 such that:\r\n$12600 -> $12.6k\r\n$342622 -> $343k\r\n$1242050 -> $1.24m\r\n\r\nI haven't found a way to specify this style of formatting. It only allows me to specify the number of decimal points, which can be too much information.\r\n\r\nFor example, specifying 2 decimal points works for $1242050 -> $1.24m, but is not appropriate for $342622 -> $342.62k.  Its just includes too much unnecessary information for displaying prices to users.\r\n\r\n Is there a way to limit the total number of digits, rather than the number of decimal places? If not, could it be added?"},"comment":{"url":"https://api.github.com/repos/adamwdraper/Numeral-js/issues/comments/96756092","html_url":"https://github.com/adamwdraper/Numeral-js/issues/194#issuecomment-96756092","issue_url":"https://api.github.com/repos/adamwdraper/Numeral-js/issues/194","id":96756092,"user":{"login":"therebelrobot","id":679178,"avatar_url":"https://avatars.githubusercontent.com/u/679178?v=3","gravatar_id":"","url":"https://api.github.com/users/therebelrobot","html_url":"https://github.com/therebelrobot","followers_url":"https://api.github.com/users/therebelrobot/followers","following_url":"https://api.github.com/users/therebelrobot/following{/other_user}","gists_url":"https://api.github.com/users/therebelrobot/gists{/gist_id}","starred_url":"https://api.github.com/users/therebelrobot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/therebelrobot/subscriptions","organizations_url":"https://api.github.com/users/therebelrobot/orgs","repos_url":"https://api.github.com/users/therebelrobot/repos","events_url":"https://api.github.com/users/therebelrobot/events{/privacy}","received_events_url":"https://api.github.com/users/therebelrobot/received_events","type":"User","site_admin":false},"created_at":"2015-04-27T17:49:31Z","updated_at":"2015-04-27T17:49:31Z","body":"Digging into the tests, it looks like you can set some of the format parameters as optional by wrapping it in `[]`, so in my example, I could do \r\n\r\n```javascript\r\nnumeral(200).format('0[.]0') // 200\r\nnumeral(200.345).format('0[.]0') // 200.3\r\n```\r\n\r\n@rickhuizinga you should be able to achieve what you want by wrapping the 0 in `[]`, like this:\r\n\r\n```javascript\r\nnumeral(12600).format('$0[.]0[0]a') // $12.6k\r\nnumeral(1242050).format('$0[.]0[0]a') // $1.24m\r\n\r\nnumeral(342622).format('$0a') // $343k = > this one is a bit trickier, since there is no way to determine if you find the following numbers significant. the previous two examples with '$0[.]0[0]' above returns \"$342.62k\"\r\n```\r\n\r\nI hope that helped a bit. Digging into the tests is sometimes the best way to determine usage for a lot of libraries. It is shown as an example on the doc website but isn't specifically called out, so that's what made it more difficult for me.\r\n\r\n@adamwdraper, would it be alright if I chipped into the docs a bit, make some of the usage cases a bit more explicit?\r\n"}}