in reply to Re^2: converting binary to decimal
in thread converting binary to decimal
replace
my $decimal = (join '', map sprintf('%0*d', $size, $_), reverse @numbe +r) =~ s/0+(?=.)//r;
with
s/0+(?=.)// for my $decimal = join '', map sprintf('%0*d', $size, $_), + reverse @number;
It's just doing math in base $n which is 10**18 in this case (because that's the largest power of 10 that works on my machine).
Change $size to 1 to see it work (more slowly) in base 10.
It's doing the same kind of thing that 'bigint' does...
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: converting binary to decimal
by harangzsolt33 (Deacon) on Jun 27, 2025 at 03:13 UTC | |
by tybalt89 (Monsignor) on Jun 27, 2025 at 04:08 UTC | |
by harangzsolt33 (Deacon) on Jul 02, 2025 at 15:51 UTC | |
by tybalt89 (Monsignor) on Jul 02, 2025 at 16:30 UTC | |
by harangzsolt33 (Deacon) on Jul 02, 2025 at 21:20 UTC |