1000 to 1k, 1000000 to 1m etc. number abbreviation

a 夏天 提交于 2019-12-26 18:22:29

问题


How can I have 1000 convert to 1k or 1200 to 1.2k? There's other solution for other programming language but I can't figure out how to make it work with AS3.

Or is there a shorter way to do it rather then if number > 1000 then make it 1k?


回答1:


Couldn't you just do something like this

var numInK = bigNumber/1000 + "k";

Maybe you could throw in a Math.round or some other checks to avoid ridiculous numbers like 3.3333333K



来源:https://stackoverflow.com/questions/24154351/1000-to-1k-1000000-to-1m-etc-number-abbreviation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!