They each are returning the integer that is greater than whatever is put in, regardless of if the input is an integer or not. :?

Seems like it…you can try System.Math.Ceiling instead. And bug report.

–Eric

Thanks!

Done.

Yeah, I also reported this as bug 32389 (though I only reported Mathf.Ceil; not Mathf.CeilToInt).

Rune

I am trying figuring out a math issue in Unity, I found this topic.

Mathf.CeilToInt(5 * 10f * 0.3f * 1f) should be **16** in Unity? Why its result is not 15?

I tried on 2017.4.39f1, 2020.1.1f1, both get 16.

It has nothing to do with Unity, it’s a limitation of how floating point numbers work. The limited precision means certain numbers (like 0.3) cannot be represented exactly and multiple consecutive operations cause rounding errors to accumulate.

https://floating-point-gui.de/basic/

In your example, the result of those multiplications is not 15, but something like 15.000000000001.