I was working on a small code snippet and I ran into an issue.
In my project, I use floor() to convert from global coordinates to “chunk” coordinates via a simple mathematic equation: floor(globalCoordinates / chunkSize) which gives me a ratio of the two values which I can then use as a coordinate system for the chunks.
The only issue is that certain values will be misrepresented and will give me the chunk right behind them as opposed the chunk ahead. Use ceil() does not remedy it, as it only applies it to the opposite values.
I attempted to use float() instead but I end up with the worst of both of them. I realize now that if there were some way to switch float from rounding up when it needs to round down (and vise-versa) I wouldn’t have said issue.
If you guys have any ideas as to what I could do to try and make an inverted round() function it would be great!