sub to_bin { my $num = shift; my $size = 0; my @result; while( $num >> $size ) { $size ++;} for (0..$size-1) { unshift @result , ( ($num & ( 2 ** $_ ) ) ? "1" : "0" ); } return join '' , @result ; }
In reply to Re: decimal to binary
by Gloom
in thread decimal to binary
by tsvika_t
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |