Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Split int into segments of max int 26

by LanX (Bishop)
on Sep 12, 2017 at 23:51 UTC ( #1199245=note: print w/replies, xml ) Need Help??


in reply to Split int into segments of max int 26

I'm confused, this sounds like if you just need to calculate modulo 26 to be able to transform 27 to AA.

Am I missing something?

edit

Something like this?

while ($n) { $i = $n % 26; unshift @vector, $i; $n -= $i; $n /= 26; } print map { chr(64+$_) } @vector;

Untested!

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!

Replies are listed 'Best First'.
Re^2: Split int into segments of max int 26
by thanos1983 (Priest) on Sep 13, 2017 at 07:40 UTC

    Hello LanX,

    I was too tired last night to even think of the modulo. Thanks for the time and effort.

    Just for future reference Perl & modulus.

    BR / Thanos

    Seeking for Perl wisdom...on the process of learning...not there...yet!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1199245]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2017-10-20 09:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (260 votes). Check out past polls.

    Notices?