hexavigesimal

convert number to combination of letters

强颜欢笑 提交于 2020-01-02 11:08:21
问题 I need to convert a number between 1 and 6000000 to a letter combination like ABCDE. Less letters is better. but i'm guessing i will need 4 or 5. Can someone point me in the right direction as how to write an algorithm to convert numbers to letters and back? only A-Z. (caps). 回答1: You need to convert to base-26 numbering: 0 is A, 1 is B, 25 is Z, 26 is BA, etc. The Hexavigesimal Wikipedia article has code for conversion to base 26. 回答2: There are 26 letters in the alphabet. TYou have 26^4 < 6

How to create a function that converts a Number to a Bijective Hexavigesimal?

£可爱£侵袭症+ 提交于 2020-01-01 05:19:07
问题 Maybe i am just not that good enough in math, but I am having a problem in converting a number into pure alphabetical Bijective Hexavigesimal just like how Microsoft Excel/OpenOffice Calc do it. Here is a version of my code but did not give me the output i needed: var toHexvg = function(a){ var x=''; var let="_abcdefghijklmnopqrstuvwxyz"; var len=let.length; var b=a; var cnt=0; var y = Array(); do{ a=(a-(a%len))/len; cnt++; }while(a!=0) a=b; var vnt=0; do{ b+=Math.pow((len),vnt)*Math.floor(a

convert number to combination of letters

南笙酒味 提交于 2019-12-06 14:34:08
I need to convert a number between 1 and 6000000 to a letter combination like ABCDE. Less letters is better. but i'm guessing i will need 4 or 5. Can someone point me in the right direction as how to write an algorithm to convert numbers to letters and back? only A-Z. (caps). You need to convert to base-26 numbering: 0 is A, 1 is B, 25 is Z, 26 is BA, etc. The Hexavigesimal Wikipedia article has code for conversion to base 26. There are 26 letters in the alphabet. TYou have 26^4 < 6 000 000 and 26^5 > 6 000 000 Then you will need 5 letters, for most of your elements Now you just need to

How to create a function that converts a Number to a Bijective Hexavigesimal?

北城余情 提交于 2019-12-03 13:36:41
Maybe i am just not that good enough in math, but I am having a problem in converting a number into pure alphabetical Bijective Hexavigesimal just like how Microsoft Excel/OpenOffice Calc do it. Here is a version of my code but did not give me the output i needed: var toHexvg = function(a){ var x=''; var let="_abcdefghijklmnopqrstuvwxyz"; var len=let.length; var b=a; var cnt=0; var y = Array(); do{ a=(a-(a%len))/len; cnt++; }while(a!=0) a=b; var vnt=0; do{ b+=Math.pow((len),vnt)*Math.floor(a/Math.pow((len),vnt+1)); vnt++; }while(vnt!=cnt) var c=b; do{ y.unshift( c%len ); c=(c-(c%len))/len;