Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Alpha base-26 to base-10...

by mr_mischief (Monsignor)
on Jun 30, 2003 at 23:17 UTC ( #270361=note: print w/ replies, xml ) Need Help??


in reply to Alpha base-26 to base-10...

Not as short but a bit clearer (to me, anyway) than the others I've seen:
sub b26_to_b10 { my @digits = reverse split //, shift; my $i = 1; my $result = 0; for ( @digits ) { $result += ( ord(lc($_)) - ord('a') + 1 ) * $i; $i *= 26; } return $result; }


Christopher E. Stith

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://270361]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2016-06-28 03:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (349 votes). Check out past polls.