in reply to Re: dec to bin conversion for large numbers
in thread dec to bin conversion for large numbers

If you have an example, I would be interested in seeing it. I've been playing around with How do I convert between decimal and binary? to help this person but keep running into the 32-bit limitation also. I tried modifying the example by vroom to no avail. Note that where vroom used "B32" I changed it to "B64". There may be a way to finesse it into working but I haven't lucked into it yet.
print dec2bin(2**31); sub dec2bin { my $str = unpack("B64", pack("N", shift)); $str =~ s/^0+(?=\d)//; # otherwise you'll get leading zeros return $str; }
This correctly produces
10000000000000000000000000000000
But if you use anything larger than 2**31, you get
11111111111111111111111111111111
@a=split??,'just lose the ego and get involved!';
for(split??,'afqtw{|~'){print $a[ord($_)-97]}