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

Re^3: Boolean calculation incorrect values

by Athanasius (Archbishop)
on Dec 24, 2015 at 08:58 UTC ( [id://1151105]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Boolean calculation incorrect values
in thread Boolean calculation incorrect values

++ for two useful and important points — 1’s vs. 2’s complement, and negation leaving a number unchanged (!) — but I have to disagree about the terminology. “Bitwise complement” is ambiguous for precisely the reasons you give, unless “1’s complement” is explicitly specified. But “bitwise negation” is unambiguous, and is the term used in the official documentation (perlop#Symbolic-Unary-Operators):

Unary "~" performs bitwise negation, that is, 1's complement. For example, 0666 & ~027 is 0640. ... Note that the width of the result is platform-dependent: ~0 is 32 bits wide on a 32-bit platform, but 64 bits wide on a 64-bit platform, so if you are expecting a certain bit width, remember to use the "&" operator to mask off the excess bits.

The Camel Book refers to ~ as “bitwise NOT” (4th Edition, p. 118).

Happy Christmas,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (2)
As of 2024-04-26 02:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found