Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: Quantum Weirdness and the Increment Operator

by eric256 (Parson)
on Jul 23, 2004 at 18:23 UTC ( [id://376953]=note: print w/replies, xml ) Need Help??


in reply to Re: Quantum Weirdness and the Increment Operator
in thread Quantum Weirdness and the Increment Operator

That is not entirely the case here though. See the following code and output.

my $f = 1; print '$f = ', $f, ' and $f + $f++ = ', $f + $f++, "\n"; my $g = 1; print '$g = ', $g; print ' and $g + $g++ = ', $g + $g++, "\n"; __END__ $f = 2 and $f + $f++ = 3 $g = 1 and $g + $g++ = 3

This is not the expected behaviour in C and i'm only auto-increment/decrement a single time.


___________
Eric Hodges

Replies are listed 'Best First'.
Re^3: Quantum Weirdness and the Increment Operator
by gam3 (Curate) on Mar 30, 2005 at 14:42 UTC
    What is undefined is the order of operation. Since ($f + $g++) == ($g++ + $f) this is normally a reasonable assumption, but of course ($f++ + $f) != ($f + $f++).
    -- gam3
    A picture is worth a thousand words, but takes 200K.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://376953]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-03-29 15:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found