in reply to Re: decimal to binary
in thread decimal to binary
did someone can do better ? ( I'm sure you can, I trust in you ;)sub to_bin { my( $num , $len ) = ( shift , 0 ); while( $num >> $len ){ $len++ ;} return reverse map {( $num & 1 << $_ ) ? "1" : "0";}(0..$len-1); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: decimal to binary
by repson (Chaplain) on Jan 25, 2001 at 11:50 UTC |