Search Issue Tracker
Won't Fix
Votes
1
Found in
2017.4.0f1
2018.3.0a1
2018.3.7f1
Issue ID
1134777
Regression
No
[2018.3][IL2CPP] Float to int conversion in returns incorrect value
Steps to reproduce:
1. Download attached project
2. Build a Standalone player with IL2CPP backend
Expected results: Angle variable is 45
Actual results: Angle variable is 44
Reproduced with: 2018.3.8f1, 2017.4.21f1
Not reproducible with: 2019.2.0a8, 2019.1.0b5
Example code:
Vector3 Direction = new Vector3(-3.0f, 0.0f, 3.0f);
float angleFloat = Vector3.SignedAngle(Direction, Vector3.forward, Vector3.up);
int angle = (int)angleFloat;
Workaround: for the float to int conversion use Convert.ToInt32()
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Progress indicator in Meta Quest Build Profile configuration is barely visible
- Slightly transparent objects disappear completely in Web Player when using RenderGraph
- Visual Scripting Components are hidden behind a throbber when Multiplayer Play Mode is running with at least one local instance
- Video Player does not throw an error when playing a video with unsupported encoding settings
- Errors indicating that TMP Extras were not Imported logged when opening the Render Pipeline Converter Window while in Play Mode
Resolution Note:
This is a precision error where IL2CPP calculates the SignedAngle to be 44.9999962 while Mono calculates it to be 45. Casting a float to int will truncate the value.
It is suggested that floats should always be rounded before casting, e.g. Mathf.Round(float), or use a dedicated function such as Convert.ToInt32().