Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

And, to make it work as you were expecting, use Math::BigInt

use 5.016; use Test::More qw(no_plan); use Math::BigInt; for (51..66) { # substr to remove 0b prefix my $s = substr(Math::BigInt->new("2")->bpow($_)->bdec->as_bin, 2); # Or: Math::BigInt->new("1")->blsft($_)->bdec->as_bin is length($s), $_, "1 << $_ -1"; } __END__ ok 1 - 1 << 51 -1 ok 2 - 1 << 52 -1 ok 3 - 1 << 53 -1 ok 4 - 1 << 54 -1 ok 5 - 1 << 55 -1 ok 6 - 1 << 56 -1 ok 7 - 1 << 57 -1 ok 8 - 1 << 58 -1 ok 9 - 1 << 59 -1 ok 10 - 1 << 60 -1 ok 11 - 1 << 61 -1 ok 12 - 1 << 62 -1 ok 13 - 1 << 63 -1 ok 14 - 1 << 64 -1 ok 15 - 1 << 65 -1 ok 16 - 1 << 66 -1 1..16

Good Day,
    Dean


In reply to Re: Converting 2**54-1 to Binary by duelafn
in thread Converting 2**54-1 to Binary by philiprbrenan

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-03-29 05:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found