• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Anyone who can, please help me out here.

notfred

Lifer
if you've got a perl interpreter installed (that includes all you linux users), can you run this, and tell me if the answers seem right to you?

It converts numbers between different bases, try 2, 8, 10, and 16 to start with, as you can check those with windows calculator. It should also do any other number base, from 2 up through 36.

here's the program:

#!/usr/bin/perl

print "Start Base: ";
$base = <>;
chomp $base;

print "End Base: ";
$ebase = <>;
chomp $ebase;

print "Number: ";
$bin = <>;
chomp $bin;

$bin =~ s/^0+//;
@bin = split(//, $bin);
@bin = &convert(@bin);
$dec = shift @bin;
foreach $bit(@bin){
$dec *= $base;
$dec += $bit;
}

while(($dec / $ebase) >= 1){
$result .= $dec % $ebase;
$result .= "|";
$dec /= $ebase;
use POSIX;
$dec = floor($dec);
}
$result .= $dec;
print "Base $ebase: ", &unconvert($result);

sub convert {
my @ret_arr;
foreach $bit(@_){
if($bit !~ m/\d/){
$bit= uc $bit;
push @ret_arr, (ord $bit) - 55;
}
else{push @ret_arr, $bit}
}
return @ret_arr;
}

sub unconvert {
my @ret_arr;
my @temp;
@temp = split /\|/, $_[0];
foreach $bit(@temp){
if($bit > 9){unshift @ret_arr, chr ($bit +55)}
else{unshift @ret_arr, $bit}
}
return @ret_arr;
}
 
I just need you to run it and see if the numbers come out ok, you don't even need to look at the code, just copy and paste to a file.
 
well, assuming you have a perl interperter installed (if you're running linux, 99% chance you do), all you'd do is this:

copy the script (#!/usr/bin/perl to the end of my post) to a file. Save that file. At the command line, type "perl name_of_saved_file"
 
Back
Top