Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

If im at 9qn it goes back to 0 why?

Asked by 3 years ago

If im at 9qn it goes back to 0 why? i dont know but how please help i was gonna release my game

0
Can you give a screenshot of your problem to be more clear? bruno13bruno13 78 — 3y
3
Why the hell do you need to go as high as 9 quintillion Optikk 499 — 3y

2 answers

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

Change your IntValues into NumberValues and the problem will disappear.

[Original answer below]

Note that Lua integers can only be accurately represented up to 2^53. You can test this by running this line in the command bar: print(2^53 + 1 == 2^53) - it'll print true.

You have a few options:

  1. Use a "big number" library (I don't know if any exist in Lua or Roblox, but it'd be worth a search on the devforum), or create your own
  2. If you don't need the accuracy, use another variable to keep track of the magnitude of the number. Using smaller numbers than required for illustration, say you chose to represent just 4 digits of accuracy and wanted to represent the number 1,234,000 -- you could store this as 1.234 in one variable and 6 in another (the 6 representing how many digits there are to the right of the number). As the number you wish to store increases/decreases, keep adjusting the magnitude variable so that your accuracy number is between 0.101 and 9.999, and your game will be able to handle almost arbitrarily large (or small) numbers! (This is how similar to how numbers are stored in Lua and other languages already, so this is only useful if you need to go even larger.)

Since your problem is at that exact number, it sounds like you're using an IntValue - I just tested it; Roblox detects that you're going too high and wraps it back down to 0. Your simplest solution is to use a NumberValue instead, which lets you hold much larger numbers.

Ad
Log in to vote
3
Answered by
Optikk 499 Donator Moderation Voter
3 years ago
Edited 3 years ago

This is the 64-bit integer limit. Straight off of google, the limit is -9223372036854775807 to 9223372036854775807. Once you surpass these limits, your number will reset.

There's no way around it (to my knowledge, at least, but I'm pretty damn sure there's no way around it), unless you try not to reach that number in your game or you create a fake number system using strings instead of numbers.

0
ok iuclds 720 — 3y
0
which idiot gave a downvote, this is fact. Nckripted 580 — 3y

Answer this question