• 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 /
  • Help Room /
avatar image
Question by FirecubeFX · Jun 10, 2018 at 08:58 PM · scripting problemerrorfloatintnumbers

How to make a number higher than Quintillion? (1000000000000000000)

Hey guys i really need your help! I got a converting script which converts Numbers like 1.000.000 to 1 Million. But when i try to add a new number higher than Quintillion it says "Integral constant is too large". (trying to make a clicking game) how can i make my number higher than Quintillion? :( Thanks for your Help, here is the script:

public class CurrencyManager : MonoBehaviour {

 private static CurrencyManager instance;
 public static CurrencyManager Instance {
     get {
         return instance;
     }
 }

 void Awake()
 {
     CreateInstance ();
 }


     void CreateInstance(){
     if (instance == null) {
         instance = this;
     }
 }
     
 public string GetCurrencyIntoString(float valueToConvert, bool currencyPerSec, bool currencyPerClick ){
     string converted;

     if (valueToConvert >=   1000000000000000000000)
     {
         converted = (valueToConvert / 1000000000000000000000f).ToString("f3") + " SEX";
     }else if (valueToConvert >= 1000000000000000000) {
         converted = (valueToConvert / 1000000000000000000f).ToString ("f3") + " QUI";
     } else if (valueToConvert >= 1000000000000000) {
         converted = (valueToConvert / 1000000000000000f).ToString ("f3") + " QUA";
     } 
     else if (valueToConvert >= 1000000000000) {
         converted = (valueToConvert / 1000000000000f).ToString ("f3") + "T";
     }
     else if (valueToConvert >= 1000000000) {
         converted = (valueToConvert / 1000000000f).ToString ("f3") + "B";
     }
     else if (valueToConvert >= 1000000) {
         converted = (valueToConvert / 1000000f).ToString ("f3") + "M";
     }
     else if (valueToConvert >= 999) {
         converted = (valueToConvert / 999f).ToString ("f3") + "K";
     }
     else if (valueToConvert <= 1000)
     {
         converted = Mathf.Round(valueToConvert).ToString();
     }


}

Comment

People who like this

0 Show 0
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

1 Reply

  • Sort: 
avatar image

Answer by andrew-lukasik · Jun 10, 2018 at 09:15 PM

When numbers this large are required you're destined to reach any value data types' limits at some point, sooner or later. No matter is it double or ulong. They're just not designed for this. You'll be better off coming up with your own little system to store these, crafted for your exact needs. For a start, you can divide number and it's exponent into 2 separate values ,double + ulong or 2 x ulong for example. Float kind of does this separation trick already. This will extend your runway considerably.

https://msdn.microsoft.com/en-us/library/296az74e.aspx

Comment

People who like this

0 Show 0 · 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

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 by June 9. 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

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

Unexpected symbol 'float' 1 Answer

How to declare an 3-dimensional array in C#? 1 Answer

The referenced script on this Behaviour is missing 0 Answers

Zipline back to the starting point error :c 0 Answers

Really need help please/A switch expression of type `float' cannot be converted to an integral type, bool, char, string, enum or nullable type 2 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