use strict; use warnings; my $nd = 186; my $nb = ''; for (reverse (0..7)) { if ($nd >= 2**$_) { $nb .= '1'; $nd -= 2**$_; } else { $nb .= '0'; } } print $nb;
In reply to Re: binary conversion
by TJPride
in thread binary conversion
by saintj0n
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |