Hi, please I want to convert long number to K,M or B. Example 1200 - 1.2k, 120000 - 1.2M. Can anyone help ? Thanks in advance
Check if the number is less than 1000. If it is set your variable to the number. If not check if it's less than 1000000. If it is, divide with 1000 and set your variable to that + K. If that doesn't fit the bill, check if the number is less than 1000000000. If it is divide with 1000000 and set your variable to that + M. Lastly divide with 1000000000 and set your variable to that + B.
Yes i can divide it as you wrote but when i do it that way it causes some problem. Example: when the is 1550 and divided with 1000 it shows 1.55K but i want it to show like this 1.5K. Can you help me solve that ?
Thanks Pandy, I divided as you wrote and set the visible numbers with toFixed() and that worked great. Thanks very much!
Yes, I realized later I missed that bit. Sorry.
Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)