sub dec2bin {
my $binary = unpack("B32", pack("N", shift));
$binary =~ s/^0+(?=\d)//; # otherwise you'll get leading zeros
return $binary;
}
to convert to binary numbers. It works good but I want to limit the numbers to 8 places to represent an 8 bit binary number. I have limited the number size to 127 so that works for positive numbers but negative numbers tend to put many 1's in front of the number. What would be a good way of going about this? In reply to binary numbers by mAineAc
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |