this shall not add the leading zeroes to the left of the digits but now it shall not remain to be multiples of 8...#!/usr/bin/perl print "Input number: "; $num = <>; chomp $num; $array[0] = $num % 2; while ($num > 1) { $num = int $num / 2; push(@array, $num % 2); } print "Binary: "; foreach(reverse @array) { print; } print "\n";
In reply to Re: Re: int2bin
by majin
in thread int2bin
by majin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |