Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^2: Quantum Weirdness and the Increment Operator

by eric256 (Parson)
on Jul 23, 2004 at 18:23 UTC ( #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
Node Status?
node history
Node Type: note [id://376953]
help
Chatterbox?
LanX ... and git in general
[erix]: I've been to Amsterdam before you were born
[LanX]: 1899?
[chacham]: Just paint the white house black again.
dbander snorts
LanX Gesundheit! :)
talexb wonders about dividing developers in those born before the Unix timestamp of zero .. and after. Spoiler: I'm before.
chacham remebers I am a mad scientist

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (12)
As of 2017-08-18 13:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Who is your favorite scientist and why?



























    Results (302 votes). Check out past polls.

    Notices?