Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^7: How the auto-increment operator works?

by AnomalousMonk (Bishop)
on Aug 02, 2020 at 01:00 UTC ( #11120222=note: print w/replies, xml ) Need Help??


in reply to Re^6: How the auto-increment operator works?
in thread How the auto-increment operator works?

For essentially the same reason that ++75 is 76 and not 86:

c:\@Work\Perl\monks>perl -wMstrict -le "my $s = '75'; printf qq{++'$s' -> }; ++$s; print qq{'$s'}; " ++'75' -> '76'
Why would a "carry" ("B" -> "C") be generated by incrementing from "e" to "f"?


Give a man a fish:  <%-{-{-{-<

Replies are listed 'Best First'.
Re^8: How the auto-increment operator works?
by zapdos (Sexton) on Aug 02, 2020 at 01:20 UTC
    Thank you very much. Now I have one more question: why my $foo = "Zz"; print ++$foo; prints "AAa" and not "AAaa"? Since there's two "z" characters and when one "z" character is incremented it produces "aa".
      > > > If a new position is needed it'll adjust to the leftmost group.

      > my $foo = "Zz"; print ++$foo; prints "AAa"

      The A is a new position the next position to the right - which is causing the "carry" - is an uppercase character A.

      > when one "z" character is incremented it produces "aa".

      Again the left a is a new position, and the position to the right is a lowercase character.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery

        ... I'm not trolling ...

        Hmmm... Starting to question this.


        Give a man a fish:  <%-{-{-{-<

        "The A is a new position the next position to the right - which is causing the "carry" - is an uppercase character."

        "Again the left a is a new position, and the position to the right is a lowercase character."

        I don't get either. This is killing me inside. And AnomalousMonk, no, I'm not trolling I swear for God.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (2)
As of 2020-10-26 07:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (250 votes). Check out past polls.

    Notices?