• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
Question by GlorifiedPig · Jun 03, 2018 at 05:18 PM · integerdouble64bit32bitlong

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?

Comment

People who like this

0 Show 12
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Tobychappell · Jun 03, 2018 at 05:26 PM 0
Share

Is this set in code like, int x = 5000000000; or via inspector?


If so, could you provide the exact line of code?

avatar image GlorifiedPig Tobychappell · Jun 03, 2018 at 05:31 PM 0
Share

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 );
 }
avatar image Tobychappell GlorifiedPig · Jun 03, 2018 at 06:14 PM 0
Share

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?

Show more comments

1 Reply

  • Sort: 
avatar image
Best Answer

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 type System.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.

Comment
GlorifiedPig
andrew-lukasik
Harinezumi

People who like this

3 Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image GlorifiedPig · Jun 04, 2018 at 06:45 AM 0
Share

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.

Unity Answers is in Read-Only mode

Unity Answers content will be migrated to a new Community platform and we are aiming to launch a public beta on June 13. Please note, Unity Answers is now in read-only so we can prepare for the final data migration.

For more information and updates, please read our full announcement thread in the Unity Forum.

Follow this Question

Answers Answers and Comments

85 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Build a 32bit app on Unity 4.3.4 ? 2 Answers

Would 64 bit Unity engine elements work in a 32 bit OS machine? 1 Answer

Editor crash after editing in a better computer 0 Answers

32bit and 64 bit plugin environment 1 Answer

Problems with 64-bit systems 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges