Large Number Issue

Get help using Construct 2

Post » Tue Jan 14, 2014 1:24 am

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)
B
24
S
3
G
1
Posts: 42
Reputation: 1,543

Post » Tue Jan 14, 2014 1:31 am

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.
ImageImageImage
B
71
S
22
G
249
Posts: 3,763
Reputation: 138,577

Post » Wed Jan 15, 2014 9:06 am

Im currently developing this game http://goo.gl/hwNebC , when the player reaches certain high score, the problem appears http://goo.gl/cQQhCS . Preview http://goo.gl/vWDrMw .jakub892014-01-15 09:12:52
B
24
S
3
G
1
Posts: 42
Reputation: 1,543

Post » Wed Jan 15, 2014 9:50 am

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.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Jan 15, 2014 7:07 pm

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.
[code]function format(num)
   if num >= 1000 then
      return format(int(num/1000)) & "," & zeropad(num%1000, 3)
   else
      return str(num)
end function[/code]
B
94
S
33
G
114
Posts: 5,359
Reputation: 73,779


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 31 guests