How do I Show 10.000 as 10K etc

0 favourites
  • 4 posts
From the Asset Store
Creepy Sprite Font suitable font for your Dark/Horror/Halloween games.
  • Hi all!

    I am creating a game where i use big yet huge numbers.

    Even to billions. Ofcourse i can't display: 10.000.000.000.000..

    Well.. It's possible but i don't want to.

    Is there any way i can display:

    1.000 as 1K

    50.000 as 50K

    1.000.000 as 1M

    1.000.000.000 as 1B etc?

    That also raises my question, is there in construct 2 a limit for the amount of numbers in a global variable and webstorages?

    Thanks in advance!

  • Would something like this work?

    if variable > 1000 set text: round(variable/1000)&"K"

    if variable > 1000000 set text: round(variable/1000000)&"M"

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • LittleStain yes it will work, tried it before. Good job for finding the answer!

  • As for the maximum number, I think C2 can really go far, but since it is using floats, the precision might be affected when you go really far into big numbers, I think the maximum UID number is somewhat close to 9 000 000 000 000 000 and I would assume so that the maximum accurate integer value would be around that, but it could be larger (still pretty high anyway)

    As for the solution LittleStain suggested, I would recommend doing a function that will format it the way you want, by comparing the number of digits the integer value of the number have.

    Edit: also you might want to use the Internation system prefixes if you go really high (k ; M ; G ; T ; P ; E ; Z ; Y)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)