Greetings, all.
I am having an issue in my code where it gives the error “The operation overflows at compile time in checked mode”. This happens with the following code:
BigInteger NitrogenLower = 71232955 * 100000000000000;
BigInteger NitrogenUpper = 74625 * 100000000000000000;
BigInteger NeonUpper = 52725 * 100000000000000000;
BigInteger NeonLower = 50328409 * 100000000000000;
BigInteger ArgonUpper = 58175 * 100000000000000000;
BigInteger ArgonLower = 56046136 * 100000000000000;
BigInteger OxygenUpper = 6455 * 1000000000000000000;
BigInteger OxygenLower = 61615909 * 100000000000000;
BigInteger CarbonDioxideUpper = 175 * 100000000000000000;
BigInteger CarbonDioxideLower = 16704545 * 1000000000000;
I believe it is likely the large numbers causing some sort of issue, or the "(int)"s and the "BigInteger"s in the following code conflicting, although the errors occur at the first number of each of the variables (e.g. 71232955, 74625 etc.). Here is where the variables are used.
NitrogenPerBreath = UnityEngine.Random.Range((int)NitrogenLower, (int)NitrogenUpper);
NeonPerBreath = UnityEngine.Random.Range((int)NeonLower, (int)NeonUpper);
ArgonPerBreath = UnityEngine.Random.Range((int)ArgonLower, (int)ArgonUpper);
OxygenPerBreath = UnityEngine.Random.Range((int)OxygenLower, (int)OxygenUpper);
CarbonDioxidePerBreath = UnityEngine.Random.Range((int)CarbonDioxideLower, (int)CarbonDioxideUpper);
I hope this is helpful to those trying to help me; I would like to know what other, more skilled (I am fairly new to unity and c#) people could advise me to do.
Thanks.