Decimal vs float



Why is there a red line on the code only in the decimal code?

Mathf.Sqrt() returns a float as the result. Doubles and floats aren’t immediately interchangeable, although in later versions of Unity you can assign a float to a double (but never the other way around). This should always work.

decimal m = (double)Mathf.Sqrt(n);
1 Like

Thanks!!! : )

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms