Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: 10high on October 04, 2017, 10:09:48 AM

Title: INT to string conversion formatting with K,M,B at the end[SOLVED]
Post by: 10high on October 04, 2017, 10:09:48 AM
Hi, I've been looking through the format options for INT to String conversion and have checked out some stack exchange C# forum posts, but I haven't found a simple solution, so I'm hoping someone here can point me in the right direction:

I have space for 5 digits to display money, so when the INT reaches 100,000 I want to display it as 100.00 K (maximum 2 digital spaces). Then when the amount reaches 1,000,000 it displays as 1.00 M, and so on.

Obviously, I can achieve this through INT comparisons and so on, but I would think there is a more straightforward way directly through the string formatting options. Here's hoping!

Thanks in advance.
Title: Re: INT to string conversion formatting with K,M,B at the end
Post by: djaydino on October 04, 2017, 01:43:33 PM
Hi,
I believe i did something similar for a idle game.

and i used an int compare for each letter,
then i think divide by the (for example 100.000) then build string.

BUt i will try if i can find it tomorrow to be sure.
Title: Re: INT to string conversion formatting with K,M,B at the end
Post by: 10high on October 05, 2017, 04:20:41 AM
Hi, thanks for taking the time to answer. With more research and better use of keywords I've found out that what I was looking for isn't possible. I was hoping for a built-in INT to string formatting option that automatically converts thousands into e.g. 20.33K.

I've now achieved what I wanted by using INT compare and the string formatting "$##.##K" or "$##.##M" respectively (in case there are any other noobs like me looking to do the same thing"