Why does Zeropad do this?

Not favoritedFavorited Favorited 0 favourites
  • 4 posts
From the Asset Store
Mouse cursor is something that the player controls and sees all the time, that's why it is so important to make it cool!
  • Hello, I want to make big numbers appear with a symbol next to them instead of full, like 1oooooo is 1m and 1005000 is 1.005m but for some reason the zeropad part (after the dot) may appear like this

    I basically make the text show the number divided by big number then zeropad number % big number / big number with 3 less zeros, 3

    can someone explain whats wrong and what I can do to fix this? I made it go up to septillions, each one has the exact same logic but with 3 extra zeros on each

    Tagged:

  • You probably meant something like:

    int(var/10^12)&”.”&zeropad(int(var/10^9)%1000, 3)&”T”

    But you could also do the same thing with:

    int(Var/10^9)/1000&”T”

    You could also do it like this to handle thousands,millions,billions,trillions,etc all at once:

    K= min(4, int(log10(var)/3))

    int(var/10^(3*k-3))/1000&tokenat(“,k,m,b,t”, k,”,”)

    If you have more suffixes you’d add them to the token at portion. I just used 4 suffixes, hence the 4 in the min().

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • thank you very much, although I got a bit confused and dont really understand what I did wrong.

    As for the last method with the K variable. If I want several variables to be shown in millions do I need to make several "K" variables too? One for each?

  • I generally just derive the formula from scratch if it’s not working. But looks like you extracted the left of the decimal, added your own decimal then did some math on the left that resulted in another decimal.

    Maybe it’s a misunderstanding on what zeropad does.

    Zeropad(1, 3) = “001”

    Zeropad(12,3) = “011”

    Zeropad(123,3) = “123”

    As to the last method. I probably should have used another variable name besides k. Anyways, you just need to change var and it should spit out for example:

    12 -> 12

    1234 -> 1.234k

    123456 -> 123.456k

    12345678 -> 12.345m

    1234567890 -> 1.234b

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