playMaker

Author Topic: INT to string conversion formatting with K,M,B at the end[SOLVED]  (Read 1792 times)

10high

  • Playmaker Newbie
  • *
  • Posts: 33
    • Cult Manager - Google Play
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.
« Last Edit: October 26, 2017, 02:34:04 AM by jeanfabre »
Cult Manager


djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
Re: INT to string conversion formatting with K,M,B at the end
« Reply #1 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.

10high

  • Playmaker Newbie
  • *
  • Posts: 33
    • Cult Manager - Google Play
Re: INT to string conversion formatting with K,M,B at the end
« Reply #2 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"
Cult Manager