Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://270361]
[atcroft]: .oO(Then there is the effect if a site changes their timezone, such as when the International Date Line was moved by the purchase of Alaska by the US from Russia in 1867, or several places (I cannot recall off-hand) that moved from one side of the Date
[atcroft]: Line to the other recently....)
[atcroft]: .oO(Then again, you also have to be careful if you had it to the database, and be aware of any assumptions it makes (such as SQLite assuming Gregorian calendar and a day of exactly 86400 seconds)...)

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2017-04-29 04:53 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (531 votes). Check out past polls.