in reply to Re^6: Infinity and Inf? (MAX_INT)
in thread Infinity and Inf?

I don't know if I understand you right, you mean to allow rational stepwidth?

Something like BASIC's FOR 3.3 TO 7.8 STEP 0.5?

IMHO the C-Style for is already meant to handle this.

Cheers Rolf

Replies are listed 'Best First'.
Re^8: Infinity and Inf? (MAX_INT)
by ikegami (Patriarch) on Sep 01, 2010 at 20:07 UTC

    Nit: C-Style for doesn't handle that very well. STEP 0.5 is ok since it's a sum of powers of 2 (2-1), but let's take STEP 0.1 instead:

    $ perl -E'for (my $_=0; $_<=7; $_+=0.1) { say }' ... 5.6 5.7 5.8 5.9 5.99999999999999 6.09999999999999 6.19999999999999 6.29999999999999 6.39999999999999 6.49999999999999 6.59999999999999 6.69999999999999 6.79999999999999 6.89999999999999 6.99999999999999

    Generate the floats from integers to avoid compounding errors:

    $ perl -E'for (0..70) { say $_/10 }' ... 5.6 5.7 5.8 5.9 6 6.1 6.2 6.3 6.4 6.5 6.6 6.7 6.8 6.9 7
Re^8: Infinity and Inf? (MAX_INT)
by BrowserUk (Patriarch) on Sep 01, 2010 at 17:22 UTC
    the C-Style for is already meant to handle this.

    Indeed. Which is (probably) why the range operator only handles integers.