Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 austinsun102 · Nov 12, 2018 at 05:30 PM · intscore system

Clicker game amount reaches max int limit

I want to make a game sort of like cookie clicker but I have a question, how do they store numbers that are bigger than an int or a long. How can you display a number from 1 - 999 and the display a multiplyer such as millions billions, trillions, or octillion. For example 1 000 000 turns into 1 million or 32 000 000 000 turns into 32 billion.

Comment
Add comment
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

3 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Eno-Khaon · Nov 12, 2018 at 07:21 PM

I offered an idea on how to handle this a few months back. Because the numbers become so large in that game genre, my suggestion was to create a class/struct which would effectively ignore numbers that are drastically different from each other and stick with the heavily optimized 32-bit math libraries.

In regard to showing long names (alternate link), you could take this class/struct and overload its ToString() function to pull or construct a name from a list based on the number of digits, as well as using that number of digits to determine whether to show 1, 2, or 3 numbers before the name.

As a rough, simplified example of this, using a value and a factor of 10 to multiply it by:

 // Excerpt from ToString()
 
 // Subtract 1 since "thousand" starts at 3 zeroes
 // Otherwise, don't subtract 1 and leave element 0 blank
 int element = (factor / 3) - 1;
 float printedValue;
 string printedString;
 if(element < longNameArray.Length)
 {
     printedValue = value * Mathf.Pow(10.0f, factor % 3);
     printedString = string.Format("{0} {1}", printedValue.ToString("F3"), longNameArray[element]);
 }
 else// if(number is larger than the list of names)
 {
     // Create the string in a format more like
     // 5.023e32056
 }
 return printedString;

Edit: Fixed formatting

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 austinsun102 · Nov 12, 2018 at 11:59 PM 0
Share

Thanks for your detailed answer even though I don't really get it lol.

avatar image austinsun102 · Nov 13, 2018 at 12:46 AM 0
Share

Can you give a full example??? Thanks

avatar image Eno-Khaon austinsun102 · Nov 13, 2018 at 04:09 AM 0
Share

Sorry to say, I haven't gotten around to writing a math library set for this for myself yet, so I don't have any complete examples to provide.

I'm happy to at least point you in the right direction when I'm able, though.

avatar image austinsun102 Eno-Khaon · Nov 13, 2018 at 03:33 PM 0
Share

It’s okay, I figured it out myself. Thanks for trying though.

avatar image
0

Answer by Vega4Life · Nov 12, 2018 at 06:37 PM

You should be using decimal, float, or double. A lot of those clicker games are only showing a few numbers anyways, once they get over a million, so precision isn't super important. Thus you could probably get away with using float or a double.


I have also seen a few games that upon reaching max limit of these values, they just show infinity - which is an interesting way of dealing with the problem.

Comment
Add comment · 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
0

Answer by Luischo · Nov 13, 2018 at 06:26 PM

As @Vega4Life say, "precision inst important on those games, so, your int variable will store how many of some unity you will show. Let me explain, in a progresion you will show:
1 to 999
1 K to 999 K (not 999000)
1 "bazillion"
1 and the like

So, you need 2 variables, 1 for the number part and the other for the string.

Comment
Add comment · 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

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

97 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 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

Cannot convert 'callable(int) as float' to 'float'. 1 Answer

Object to int 1 Answer

c# convert int to string 2 Answers

Having a GUI text as a int 3 Answers

How to write "if (var int = var int 2)" ? 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