- Home /
Any number that exceeds 32 bits crashes game
I've tried using a long, I've tried using a double, I've even tried using an Int64, but if my number exceeds the 32-bit integer limit, my game crashes. I've tried debugging it but there are no crash logs appearing. I have literally removed every single reference to the number and only put it to equal like 5 billion on startup but it still crashes my game. Is there something I need to tweak in the player settings or how do I get rid of this issue?
Is this set in code like, int x = 5000000000; or via inspector?
If so, could you provide the exact line of code?
In the code.
void Start() {
cash = 5000000000;
LoadGame();
InvokeRepeating( "CountTimePlayed", 1.0f, 1.0f );
InvokeRepeating( "SaveGameTimer", 15.0f, 15.0f );
InvokeRepeating( "CheckForLevelUp", 5.0f, 15.0f );
}
I cant seem replicate this. I did: long xl = 5000000000;
And i built the game against both x86 and x86_64 and both built and ran without crashing.
Is your operating system 32bit?
Answer by Bunny83 · Jun 04, 2018 at 02:04 AM
Ok, just to clear some confusion here:
First of all the type
long
is just an alias for the typeSystem.Int64
. So they are literally the same type and there will be no difference using long or Int64.The type long works even on 32bit architectures / operating systems. It is just a signed number type with 64 bits. Just like the type decimal which has 128 bits and works on 32bit hardware / software
setting a long variable to any kind of value will never crash or hang your application.
It's not clear what you mean by crash. In most cases you do not experience a crash but a hang which is a quite different thing. If your application hangs in almost all cases you have some kind of infinite loop. Do not concentrate on the setting of the value but on where you use it.
We can't help you any further without more information. All i can say i've used longs, and ulongs in 32 / 64 standalone build as well as android or webGL builds without any problems. And yes, my values did exceed the 32 bit border, otherwise i wouldn't have used a long in the first place. So if you want further help edit your question and include your code.
Thanks a lot for your help. Turns out I had a function to include the maximum amount of upgrades you can fit into the amount of cash you have, and that number was a regular integer and exceeded 32 bits, so it hanged the game.
Your answer
Follow this Question
Related Questions
Editor crash after editing in a better computer 0 Answers
32bit and 64 bit plugin environment 1 Answer
Idle Game Currency Optimizing 1 Answer
Problems with 64-bit systems 0 Answers
Can 32bit Unity editor make 64bit games? 0 Answers