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? :frowning: 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();
    }

}

You need to remember that unity is 3D engine. transform.LookAt(target, Vector3.up) does work, put in update() switch editor to 3D mode and drag around your object in play mode. You'll see how it's rotating. As for solution, put your script on empty object, put inside that object another object with bullet sprite and rotate that sprite -90 on Y axis. (With default unity set up, LookAt(target, Vector3.up))

1 Answer

1

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

Just tried it out, and it worked, thank you! Now you can see the enemy bullet! However, it still doesn't seem to be facing the player. Do you know how I could do that? Again, thanks so much!