code: public static double[] range2Bins( double min, double max, double step, boolean doLastEqual ) {
          double intervalsDouble = (max - min) / step;
  
          int intervals = (int) intervalsDouble;
          double rest = intervalsDouble - intervals;
          if (rest > D_TOLERANCE) {
              intervals++;
          }
  
          double[] bins = new double[intervals + 1];
          int count = 0;
          double running = min;
          for( int i = 0; i < intervals; i++ ) {
              bins[count] = running;
              running = running + step;
              count++;
          }
          if (doLastEqual) {
              bins[intervals] = running;
          } else {
              bins[intervals] = max;
          }
          return bins;
      }
docs: Creates an array of bins from a range and a step to use.
  
  <p>Note that if the step doesn't split the range exactly, the last bin
  will be smaller if doLastEqual is set to <code>false</code>.</p>
  
  @param min the min value.
  @param max the max value.
  @param step the wanted size of the bins.
  @param doLastEqual make also the last bin of equal step size.
  @return the array of bin bounds.