diff --git a/gdsc-core-ij/src/main/java/uk/ac/sussex/gdsc/core/ij/HistogramPlot.java b/gdsc-core-ij/src/main/java/uk/ac/sussex/gdsc/core/ij/HistogramPlot.java index ad2fa91c..6fc5f25e 100644 --- a/gdsc-core-ij/src/main/java/uk/ac/sussex/gdsc/core/ij/HistogramPlot.java +++ b/gdsc-core-ij/src/main/java/uk/ac/sussex/gdsc/core/ij/HistogramPlot.java @@ -763,8 +763,9 @@ int getOrComputeNumberOfBins(double[] limits, double[] values) { bins = getBinsSqrtRule(data.size()); break; } - // In case of error (N=0 or Infinity in the data range) - if (bins == Integer.MAX_VALUE) { + // In case of error (N=0 or Infinity/NaN in the data range) + // Check for bins=0 and bins=MAX_VALUE using overflow trick + if (bins + 1 <= 1) { bins = getBinsSqrtRule(data.size()); } }