Search Issue Tracker

Fixed

Votes

10

Found in

4.6.4p2

Issue ID

700792

Regression

No

[IL2CPP] Mathf.RoundToInt method doesn't work correctly

IL2CPP

-

To Reproduce:

1. Run the attached script with mono/il2ccpp
2. Observe that IL2CPP returns incorrect values for:

Mathf.RoundToInt(4.5f)
Mathf.RoundToInt(0.5f + float.Epsilon)
Mathf.RoundToInt(0.5f - float.Epsilon)

Comments (1)

  1. hitorijanai

    Jun 11, 2015 00:57

    I also have this problem after upgrading Unity to 4.6.5.p3. It seems like a little bug for many, but is a big problem for networked games. I think the real bug is that when you cast a float to int. My temporary solution is to cast to double before casting it to integer (float -> double -> int). Hope this helps

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.