Search Issue Tracker
Postponed means that the issue was either a feature request or something that requires major refactoring on our side. Since that makes the issue not actionable in the close future we choose to close it as Postponed and add it on our internal roadmaps and technical debt pages instead.
Postponed
Votes
1
Found in
2017.1.1f1
Issue ID
993313
Regression
No
C# compiler constant folding issue with float operations
To reproduce:
1. Open the project, attached by the tester (ApproximatelyBug.zip)
2. Open the "scene" scene
3. Enter Play mode
4. Observe the console
Expected: Mathf.Approximately ((1.7f - 0.2f) % 1.5f, 0f) returns TRUE as does Mathf.Approximately (1.5f % 1.5f, 0f)
Actual: Mathf.Approximately ((1.7f - 0.2f) % 1.5f, 0f) returns TRUE (should be true), but Mathf.Approximately (1.5f % 1.5f, 0f) returns FALSE
Reproduced in 5.6.5f1, 2017.1.1f1, 2017.2.1p3, 2017.3.0p4, 2018.1.0b5
==========
Resolution:
This is actually a bug in the Mono C# compiler as it evaluates (1.7f - 0.2f) % 1.5f not to the constant value 0 but a very small floating point number. I have filed a bug upstream.
In addition, we plan on migrating to the Roslyn compiler in the future. This bug is not present there. I am resolving this bug for now, either to be fixed by Mono project or by migration to Roslyn.
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- ArgumentOutOfRangeException when manipulating the Project Settings search bar
- [Linux] Touch freezes in Player when any mouse button is clicked
- UnityEngine.Rendering.Volume.OnEnable() is called twice before OnDisable() creating multiple copies of the same volume when a volume is enabled right after Domain Reload when entering Play Mode
- Hinge Joint transforms are reset when toggling the "useMotor" property
- Motion Vector texture reports incorrect Mesh data when Mesh is coming from off-screen
Add comment