in reply to Alpha base-26 to base-10...
Here is some similar code that I wrote a while ago as part of Spreadsheet::WriteExcel::Utility. The code is verbatim although I was tempted to take out some of the parentheses:
# Convert base26 column string to number # All your Base are belong to us. my @chars = split //, $col; my $expn = 0; $col = 0; while (@chars) { my $char = pop(@chars); # LS char first $col += (ord($char) -ord('A') +1) * (26**$expn); $expn++; }
As an aside. Any particular reason for using POSIX::pow()?
And as another aside the POSIX strtol() function will convert base 26 (or bases from 2 to 36) to base 10, although not for this base 26 format.
--
John.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Alpha base-26 to base-10...
by Boots111 (Hermit) on Jul 01, 2003 at 05:45 UTC | |
by jmcnamara (Monsignor) on Jul 01, 2003 at 17:05 UTC | |
Re: Re: Alpha base-26 to base-10...
by eduardo (Curate) on Jul 01, 2003 at 00:28 UTC |
In Section
Seekers of Perl Wisdom