Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^4: The mystery of double negation (bool 0)

by zwon (Abbot)
on Jul 13, 2015 at 20:55 UTC ( #1134593=note: print w/replies, xml ) Need Help??


in reply to Re^3: The mystery of double negation (bool 0)
in thread The mystery of double bitwise negation

Interestingly, !1 is "", ~~(!1) is 0, but ~~("") is "".
$ perl -MO=Deparse -E'say !1; say ~~(!1); say ~~("");' use feature 'current_sub', 'evalbytes', 'fc', 'say', 'state', 'switch' +, 'unicode_strings', 'unicode_eval'; say !1; say 0; say ''; -e syntax OK

Replies are listed 'Best First'.
Re^5: The mystery of double negation (SvPOK)
by tye (Sage) on Jul 13, 2015 at 21:51 UTC

    Of course. !1 is a dual-value of empty string plus 0. Bitwise operators operate on integers if the scalar has an authoritative ("public") numeric value, otherwise they operate on strings. QED.

    - tye        

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2020-05-26 13:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If programming languages were movie genres, Perl would be:















    Results (150 votes). Check out past polls.

    Notices?