给定基数为36的YPAYPA,是否有Java中的库函数将其转换为十进制数?
The below returns a String representation, in decimal, of the number.
Long.valueOf("YPAYPA", 36).toString();
From the J2SE docs
这甚至可以用于大数字。
new BigInteger("YPAYPA", 36).toString();
This sounds like a homework question. If it's not, then I apologize, but for now I will simply post some information that will help you find the right answer.
Since this is a base 36 number, I will assume that the values are [0-9][AZ], the values of the letters are A = 10, B = 11, etc. The easiest way of solving this is through powers. The position furthest to the right (A in your example) is 10 * (36 ^ 0), which would equal 10. P would be (15 * 36 ^ 1).
Essentially it is the value of the digit, multiplied by the result of the base raised to the 0-based position it is in. Our decimal system works exactly the same way (10 ^ 0, 10 ^ 1, etc).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.