Here’s a puzzler for you.
I’m designing continuous terrain exploration by dynamically loading/unloading 100x100 blocks of tiles.
Given the following coordinates (same for x or y-axis):
...|-300 ... -201|-200 ... -101|-100 ... -1|0 ... 99|100 ... 199|200 ... 299|...
Can you come up with a simple function that given an int, returns the anchor point? The anchor point is the left-hand number in the range and is a multiple of 100. For example for any value between -200 … -101 return -200. For 100 … 199 return 100.
The biggest problem for me is that integer division of negative values seems to be different from language to language! (-1 / 100) gives me -1 in python but 0 in Java. ???
Otherwise I’d use f(x) = x / 100 * 100