string.digits, long
时间: 2023-11-25 14:07:26 浏览: 37
string.digits is a string constant that contains all the numerical digits from 0 to 9.
long is a data type that is used to represent integers with a very large range of values. In Python 2.x, long integers are represented by appending an "L" to the end of the number or by using the built-in long() function. In Python 3.x, long integers are no longer a separate data type and are automatically converted to int when necessary.
相关问题
java long类型 三十二进制转十进制
同样可以使用以下代码将三十二进制数转换为十进制数,不过需要使用 long 类型来存储结果:
```
public static long toDecimal(String thirtyTwo) {
String digits = "0123456789ABCDEFGHIJKLMNOPQRSTUV";
long decimal = 0;
for (int i = 0; i < thirtyTwo.length(); i++) {
char c = thirtyTwo.charAt(i);
int digit = digits.indexOf(c);
decimal = decimal * 32L + digit;
}
return decimal;
}
```
使用方法同上,只需将返回值类型改为 long 即可:
```
long decimal = toDecimal("3I2");
System.out.println(decimal);
```
输出结果依然为 1234。
java long类型的三十二进制转十进制
同样可以使用以下代码将三十二进制数转换为十进制数,不过需要使用 long 类型来存储结果:
```
public static long toDecimal(String thirtyTwo) {
String digits = "0123456789ABCDEFGHIJKLMNOPQRSTUV";
long decimal = 0;
for (int i = 0; i < thirtyTwo.length(); i++) {
char c = thirtyTwo.charAt(i);
int digit = digits.indexOf(c);
decimal = decimal * 32L + digit;
}
return decimal;
}
```
使用方法同上,只需将返回值类型改为 long 即可:
```
long decimal = toDecimal("3I2");
System.out.println(decimal);
```
输出结果依然为 1234。
相关推荐
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)