Quantcast
Channel: Questions in topic: "round"
Viewing all articles
Browse latest Browse all 87

Weird behavior with % operator

$
0
0
So i'm calculating some positions and my problem is that this line: Mathf.Abs(Mathf.Round(pos.x * 100) / 100) % (4 * scale) returns 115,6 where it should return 0 (115,6/115,6 should give 1). I thought it has to do with some calculation inaccuracies but when i print this line: Mathf.Abs(Mathf.Round(346.8f * 1000) / 1000)) / (4 * 28.9f) it returns 3 (as it should). So my question is what's the diffrence here? i'm not changing any values or anything.

Viewing all articles
Browse latest Browse all 87

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>