in reply to Re: Re: Re: Why does it return 0?
in thread Why does it return 0?
I wasn't thinking when I tried to do it with an if statement. I don't get any errors with this and it gives me the right number. I just didn't understand the code that you gave me at first. What does %b do?sub dec2bin { my $binnumb; while($inNumber > 0) { my $binary = $inNumber % 2; print $inNumber; print "\n"; $inNumber = int($inNumber / 2); $binnumb .= $binary; print $binnumb; print "\n"; } $binnumb = reverse $binnumb; return $binnumb; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Re: Why does it return 0?
by ysth (Canon) on Feb 05, 2004 at 03:24 UTC |