Fix rounding issues with histograms

Since we determine the max (and min) value to create the bins,
all values should always fall in the created bins,
but it doesn't always work due to rounding issues.
To fix this all values larger than the mx value (right side of the last
bin)
and smaller than mn are ignored, otherwise extra bins with NaN can
occur.
This can cause a couple of values to be not counted.