Hi,
So the problem is that i need to convert a large decimal number to binary.
The script below works fine for most numbers:
sub dec2bin {
my $str = unpack("B32", pack("N", shift));
$str =~ s/^0+(?=\d)//;
return $str;
}
But if the decimal gets really big i only get "11111111111111111111........111111" returned.....
Anyone have a solution for this?
I'm working on a manual algorithm and will post it if i get it to work....
Cheers,
w_s
:biggrin:
Perl - Converting Dec to Binary
-
- Moderator Emeritus
- Posts: 6866
- Joined: 12 Dec 2003, 02:00
- Location: JHB
- Contact:
-
- Moderator Emeritus
- Posts: 6866
- Joined: 12 Dec 2003, 02:00
- Location: JHB
- Contact: