core/src/main/java/org/jruby/RubyNumeric.java
public static double floatStepSize(double beg, double end, double unit, boolean excludeLast) {
        double n = (end - beg)/unit;
        double err = (Math.abs(beg) + Math.abs(end) + Math.abs(end - beg)) / Math.abs(unit) * DBL_EPSILON;

        if (Double.isInfinite(unit)) {
            if (unit > 0) {
                return beg <= end ? 1 : 0;
            } else {
                return end <= beg ? 1 : 0;
            }
        }

        if (unit == 0) {
            return Float.POSITIVE_INFINITY;
        }

        if (err > 0.5) err = 0.5;
        if (excludeLast) {
            if (n <= 0) {
                return 0;
            }
            if (n < 1) {
                n = 0;
            } else {
                n = Math.floor(n - err);
            }
        } else {
            if (n < 0) {
                return 0;
            }
            n = Math.floor(n + err);
        }
        return n + 1;
    }
/**
     * Returns the number of unit-sized steps between the given beg and end.
     *
     * NOTE: the returned value is either Double.POSITIVE_INFINITY, or a rounded value appropriate to be cast to a long
     *
     * MRI: ruby_float_step_size
     */
Returns the number of unit-sized steps between the given beg and end.
NOTE: the returned value is either Double.POSITIVE_INFINITY, or a rounded value appropriate to be cast to a long


Returns the number of unit - sized steps between the given beg and end . NOTE : the returned value is either Double . POSITIVE_INFINITY or a rounded value appropriate to be cast to a long
public static double floatStepSize(double beg, double end, double unit, boolean excludeLast) {
        double n = (end - beg)/unit;
        double err = (Math.abs(beg) + Math.abs(end) + Math.abs(end - beg)) / Math.abs(unit) * DBL_EPSILON;
        if (Double.isInfinite(unit)) {
            if (unit > 0) {
                return beg <= end ? 1 : 0;
            } else {
                return end <= beg ? 1 : 0;
            }
        }
        if (unit == 0) {
            return Float.POSITIVE_INFINITY;
        }
        if (err > 0.5) err = 0.5;
        if (excludeLast) {
            if (n <= 0) {
                return 0;
            }
            if (n < 1) {
                n = 0;
            } else {
                n = Math.floor(n - err);
            }
        } else {
            if (n < 0) {
                return 0;
            }
            n = Math.floor(n + err);
        }
        return n + 1;
    }
public static double floatStepSize ( double beg , double end , double unit , boolean excludeLast ) { double n = ( end - beg ) / unit ; double err = ( Math . abs ( beg ) + Math . abs ( end ) + Math . abs ( end - beg ) ) / Math . abs ( unit ) * DBL_EPSILON ; if ( Double . isInfinite ( unit ) ) { if ( unit > 0 ) { return beg <= end ? 1 : 0 ; } else { return end <= beg ? 1 : 0 ; } } if ( unit == 0 ) { return Float . POSITIVE_INFINITY ; } if ( err > 0.5 ) err = 0.5 ; if ( excludeLast ) { if ( n <= 0 ) { return 0 ; } if ( n < 1 ) { n = 0 ; } else { n = Math . floor ( n - err ) ; } } else { if ( n < 0 ) { return 0 ; } n = Math . floor ( n + err ) ; } return n + 1 ; }
Returns the number of unit-sized steps between the given beg and end.
Returns the number of unit - sized steps between the given beg and end .