Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 /
  • Help Room /
avatar image
0
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
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

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

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

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

Unexpected symbol 'float' 1 Answer

Admob Errors 1 Answer

Failed to parse configuration for gameId: xxxxxx System.Threading._ThreadPoolWaitCallback:PerformWaitCallback() 3 Answers

Auto Set vs Manual Decrease (How to do both?) 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