Large Number Issue

0 favourites
  • 5 posts
From the Asset Store
Jump on numbers in the proper order and reach the sun!
  • Hi, I have a problem with large number. If the value in global variables is higher than number 100200300400500600700800900, I can't save it and so it doesn't appear properly (i.e.: 1.002003004005006e+21). Does anybody know why?

    Another thing about values - is there a way to apply the currency format to the numbers globally? (for really large number, i.e.: 100,200,300,400,500,600,700,800,900,000)

  • What are you trying to do? Computers can't store infinitely large numbers - there's always a limit. Looks like you are encoding something, so a string would be better.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I?m currently developing this game goo.gl/hwNebC , when the player reaches certain high score, the problem appears goo.gl/cQQhCS . Preview goo.gl/vWDrMw .

  • I'm not sure someone will bake a gazillion pizza's, but if you really want to be able to do this maybe you should split up the number.

    so if 1 million pizza's is reached, add 1 to the variable millions.

    and if the variable millions exists add the variable to the string showing the score.

  • When you see "e+21" at the end of the number it means the number is being displayed in scientific notation. So 1.002003004005006e+21 means 1.002003004005006*10^21. Any digits before "e" are the significant digits and with JavaScript numbers you get about 17 significant digits.

    Here is some psuedo code for a function to convert any number to currency format text.

    function format(num)
       if num >= 1000 then
          return format(int(num/1000)) & "," & zeropad(num%1000, 3)
       else
          return str(num)
    end function
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)