Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^5: Infinity and Inf? (MAX_INT)

by LanX (Bishop)
on Sep 01, 2010 at 15:09 UTC ( #858359=note: print w/replies, xml ) Need Help??


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

Thanks but thats not my problem, its the break of symmetry between .. and ++ which "bugs" me!

IMHO it doesn't make sense to restrict the rangeoperator to signed integers when floats can still represent bigger integers (which are perfectly transparent when used with arithmetic operators).

Cheers Rolf

Replies are listed 'Best First'.
Re^6: Infinity and Inf? (MAX_INT)
by BrowserUk (Pope) on Sep 01, 2010 at 16:42 UTC
    IMHO it doesn't make sense to restrict the rangeoperator to signed integers when floats can still represent bigger integers

    I can sort of sympathise with that.

    But for counterpoint, does it make sense to restrict the iteration of a float iterator to unitary integer increments?


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      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

        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
        the C-Style for is already meant to handle this.

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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://858359]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (11)
As of 2017-10-17 13:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (232 votes). Check out past polls.

    Notices?