Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Making all nibble zero lower than the offset

by Cristoforo (Curate)
on Nov 20, 2018 at 03:02 UTC ( #1226045=note: print w/replies, xml ) Need Help??


in reply to Making all nibble zero lower than the offset

Hello spriyada29,

I don't know if this is a possible answer but it works with the example binary string you provided.

#!/usr/bin/perl use strict; use warnings; my $bin = 0b1111_1111_1111; for my $factor (3,5) { # round up to multiple of 4 my $shift = $factor + (-$factor % 4); my $c = $bin >> $shift; $c <<= $shift; printf "%b\n", $c; }
Prints out:
111111110000 111100000000

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2020-09-20 07:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If at first I donít succeed, I Ö










    Results (120 votes). Check out past polls.

    Notices?