Granularity in, garbage out

Okay, I found the problem with my program. You know, the one about increasing granularity instead creates garbage. Stupid mistake. First-year-university kind of mistake.
Essentially I was putting a long into a short. For the non-programmers reading this, let me explain. Integer numbers can (mostly) be stored in in either of two ways. They can be stored in a short, which means you are only allowed about five digits, or they can be stored in a long, which allows about ten digits. (This is GREATLY simplified.) If you try to put a ten digit number into a five digit place, it lops off all the higher digits. In other words, it becomes much smaller.
This problem didn’t really show up until I started quadrupling the size of a map by doing the increased granularity. A low level function was getting the size of the map and going through every height-point on it and converting it appropriately. Except it thought the size of the map was 257 times smaller than it actually was due to the long/short problem. So instead of doing the conversion, it was only operating on a small part of the map. The rest was unconverted and looked effectively like garbage.
Because I knew what to look for, I found a similar problem with my function that calculates the percentage of ocean coverage. (Probably because I copied the code from the first function.) Except in this case, it was only telling me the percentage of ocean coverage in the top few rows of my map. Not the same thing.