# Converting

• 08-21-2011, 06:02 PM
PhQ
Converting
How can I convert an int like for example convery 10000 to 10k, convert 150000 to 150k 1000000 to 1m and etc.

How can I do this?
• 08-21-2011, 06:06 PM
Norm
You want to take a int value, say 10000 and convert it to the String "10k".
Divide the int by 1000, convert the results to a String and concatenate a "k".
Same logic for "1m"
• 08-21-2011, 06:22 PM
PhQ
Quote:

Originally Posted by Norm
You want to take a int value, say 10000 and convert it to the String "10k".
Divide the int by 1000, convert the results to a String and concatenate a "k".
Same logic for "1m"

How can I check whether or not it has a decimal? For example if it is 1500 it would say 1.5k but if it's 1000 it would say 1k.

EDIT:: nvm, figured it out! :)

Thank you!
• 08-21-2011, 06:28 PM
Norm
Quote:

How can I check
You could use the if statement to check the value of a variable.
You could check to see if there are remainders after a division by 1000 by using the % operator.