Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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
0
Question by el-RERS · Jul 12, 2014 at 01:35 AM · arraysintcrashescharacters

eleven characters in an int[] array makes unity crash?

Soooo... I'm super new to unityscript so I'm sorry if this sounds like a dumb question (and sorry for my english as well, I'm a spanish-native speaker actually :/).

Anyway, I run into this weird problem: I was practicing a little of arrays with this extremely simple code which works perfectly:

 var miarray = new int[2];
  
  function Start () {
  
  miarray[0]=1544444414; 
  miarray[1]=1244444412;
  
  Debug.Log("array[] 0 = " + miarray[0]);
  Debug.Log("array[] 1 = " + miarray[1]);
  
     }

However, if I ever decide to add a single character to any of these two variables, Unity crashes! ... this is the code:

 var miarray = new int[2];
  
  function Start () {
  
  miarray[0]=15444444141; //11 characters for unity to crash!
  miarray[1]=1244444412;
  
  Debug.Log("array[] 0 = " + miarray[0]);
  Debug.Log("array[] 1 = " + miarray[1]);
     
     }
 

Unity shuts down by itself and I get a "Unity Bug Reporter" window. So uhm... is this normal? (I'm using the free version of Unity for now by the way). Thanks in advance!

Comment
Add comment · Show 1
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 el-RERS · Jul 12, 2014 at 02:55 AM 0
Share

Also, I'd like to add that now I'm absolutely sure that what fafase says is the cause of the crash because when I give my variable a value of 5000000000 (a ten-character number but greater than 2billion) unity crashes again... so yeah...

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by fafase · Jul 12, 2014 at 01:38 AM

ints are limited as they are 32 bits, they can only hold values from . if you need bigger -2 to 2 billion.

http://msdn.microsoft.com/en-us/library/5kzh1b5w.aspx

Use uint and you get from 0 to 4 billions.

Floats can hold more but loses precision to some extent.

http://msdn.microsoft.com/en-us/library/b1e65aza.aspx

If you need a large integer value use a long

http://msdn.microsoft.com/en-us/library/ctetwysk.aspx

Comment
Add comment · Show 4 · 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 el-RERS · Jul 12, 2014 at 01:40 AM 0
Share

wow! that was quick! thanks for the answer! :D

avatar image Bunny83 · Jul 12, 2014 at 01:46 AM 0
Share

@fafase:
While that is true, Unity really shouldn't crash because of assigning a long literal to an int array element. Since UnityScript usually casts automatically that line should actually work. Even if not it should throw either a compiler error or a runtime exception ins$$anonymous$$d of crashing...

@el-rers:
You should file a bug report if you're sure that this is actually the cause of the crash.

avatar image el-RERS · Jul 12, 2014 at 01:59 AM 0
Share

I tried, but the thing gets stuck in "uploading report" :/

avatar image fafase · Jul 12, 2014 at 01:37 PM 0
Share

Actually it should even throw an error while saving the script.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

A node in a childnode? 1 Answer

Don't get my app running on device IOS5, Xcode 4.2 2 Answers

pick a random int with the value of 1 from an array 2 Answers

converting "int" to "string" 2 Answers

hi!does any know how to make an endless track 1 Answer


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