The position shoul be digit :-)
In either case you do not need the index nor the ** operator.
my @digit = reverse split //, $bin; my $num = 0; for my $bit (@digit) { $num = $num * 2 + $bit; } print "\n$num\n";
Jenda
Enoch was right!
Enjoy the last years of Rome.
In reply to Re^2: binary converter
by Jenda
in thread binary converter
by perlnoobz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |