Thing is changing the area to double also wouldn’t radically change the values like this.
Example:
private void Start()
{
var sb = new StringBuilder();
var arr = new[]
{
(5, 0.02112716),
(10, 0.04121076),
(15, 0.07670123),
(20, 0.1153387),
(25, 0.1618201),
(30, 0.2244108),
(35, 0.3140703),
(40, 0.3879602),
(45, 0.5),
(50, 0.6103955)
};
foreach(var tup in arr)
{
sb.AppendLine(string.Format("{0} | {1} | {2} | {3}", tup.Item1, tup.Item2, DoSingle(tup.Item1, (float)tup.Item2), DoDouble(tup.Item1, tup.Item2)));
}
Debug.Log(sb.ToString());
}
private float DoSingle(float alpha, float area)
{
float alphaRad = Mathf.Deg2Rad * alpha; //alpha is a positive float from 0 to 90
float x = (-Mathf.Sin(alphaRad) + Mathf.Sqrt(Mathf.Pow(Mathf.Sin(alphaRad), 2) - 4 * (-2 * area))) / 2;
return x;
}
private double DoDouble(double alpha, double area)
{
double alphaRad = Mathf.Deg2Rad * alpha; //alpha is a positive float from 0 to 90
double x = (-System.Math.Sin(alphaRad) + System.Math.Sqrt(System.Math.Pow(System.Math.Sin(alphaRad), 2) - 4 * (-2 * area))) / 2;
return x;
}
This results in:
5 | 0.02112716 | 0.1665491 | 0.166549116387459
10 | 0.04121076 | 0.2131091 | 0.213109141545409
15 | 0.07670123 | 0.283082 | 0.283082035036858
20 | 0.1153387 | 0.3388152 | 0.338815237115605
25 | 0.1618201 | 0.3955613 | 0.395561324829143
30 | 0.2244108 | 0.4650676 | 0.465067550398975
35 | 0.3140703 | 0.556057 | 0.55605701331107
40 | 0.3879602 | 0.6162705 | 0.616270516939687
45 | 0.5 | 0.7071067 | 0.707106782620556
50 | 0.6103955 | 0.786378 | 0.786378063041708
Note that the float and double results (3rd and 4th columns) are effectively the same value. Only difference being the number of sig values to the right.
But in the end, the most significant values towards the left are equal.
0.1665491 ~ 0.16654911…
Your values are vastly different relative speaking. They’re not even consistently different. They start out 1.17 times larger, shoot up to 1.68 times different by the 5th entry, then start dropping down in scale to 1.58 by the end. A float->double bug would be more linear. This curved result in difference implies some error with a curve… curves like sines and squareroots.
…
I don’t know what caused your original issue, but I’m just clarifying for future people, that no… changing from float to double is NOT what fixed the problem.
I’m with @Bunny83 in that you probably were running a different version of your code. Potentially from the result of not saving (you say you closed it and reopened the next day. You could have saved it when you closed it. But it wasn’t saved before you closed it and ran your first test which was your results in OP).