Index: /trunk/psLib/src/math/psStats.c
===================================================================
--- /trunk/psLib/src/math/psStats.c	(revision 15047)
+++ /trunk/psLib/src/math/psStats.c	(revision 15048)
@@ -13,6 +13,6 @@
  * use ->min and ->max (PS_STAT_USE_RANGE)
  *
- *  @version $Revision: 1.216 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-09-20 23:59:01 $
+ *  @version $Revision: 1.217 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-09-28 00:36:30 $
  *
  *  Copyright 2006 IfA, University of Hawaii
@@ -1697,5 +1697,7 @@
         // Calculate the number of bins.
         // XXX can we calculate the binMin, binMax **before** building this histogram?
-        long numBins = (max - min) / binSize;
+	// if the range is too absurd, adjust numBins & binSize
+        long numBins = PS_MAX (5, PS_MIN (10000, (max - min) / binSize));
+	binSize = (max - min) / (float) numBins;
         psTrace(TRACE, 6, "The new min/max values are (%f, %f).\n", min, max);
         psTrace(TRACE, 6, "The new bin size is %f.\n", binSize);
