Treats densities outside the grid as those of the closest boundary
changed truncation to rounding