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

Re^2: Flipping partial bits

by jszinger (Scribe)
on Nov 13, 2020 at 16:26 UTC ( [id://11123634]=note: print w/replies, xml ) Need Help??


in reply to Re: Flipping partial bits
in thread Flipping partial bits

The high bit does not need to be masked. Something like:
for my $x (0..0xff) { my $y = ( $x & 0x80 ) ? -($x ^ 0xff) : $x; say "$x $y" }

Replies are listed 'Best First'.
Re^3: Flipping partial bits
by haukex (Archbishop) on Nov 14, 2020 at 12:08 UTC
    The high bit does not need to be masked.

    Yes, that's true, though I felt the specs were a little bit lacking (hence my request for more examples), which is why I played it safe and showed how to do the masking too.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2024-03-29 12:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found