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; } #### 10000000000000000000000000000000 #### 11111111111111111111111111111111
## 10000000000000000000000000000000 ##
## 11111111111111111111111111111111