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();
}
}
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.