Razenpok / BreakInfinity.cs

Double replacement for numbers that go over 1e308
MIT License
212 stars 33 forks source link

Number incorrectly hits Infinity. #13

Closed nixonjoshua98 closed 3 years ago

nixonjoshua98 commented 3 years ago

Number goes to Infinity after stage 5144. What am I doing wrong?

    public static BigDouble CalcEnemyHealth(int stage)
    {
        BigDouble x = BigDouble.Pow(1.35, Mathf.Min(stage - 1, 65));
        BigDouble y = BigDouble.Pow(1.15, Mathf.Max(stage - 65, 0));

        Debug.Log(y.ToString("E3"));

        return BigDouble.Multiply(15, BigDouble.Multiply(x, y));
    }

Stage 5143 will display 1.674E+308 here but stage 5144 will display NaNE+0. The returned value will show Infinity at stage 5144.