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; }
In reply to Re: Re: Re: Re: Why does it return 0?
by mAineAc
in thread Why does it return 0?
by mAineAc
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |