当前位置:网站首页>1-4 进制表示与转换
1-4 进制表示与转换
2022-06-27 07:05:00 【WayserKON】
进制表示
- 八进制与十六进制的表示。
public class Main {
public static void main(String[] args){
int x = 0x1f; // 十六进制
System.out.println(x); // output: 31
x = 0x1F;
System.out.println(x); // output: 31
x = 070; // 八进制
System.out.println(x); // output: 56
long y = 0x1f;
System.out.println(y); // output: 31
y = 0x1F;
System.out.println(y); // output: 31
y = 070;
System.out.println(y); // output: 56
}
}
进制转换
- 二进制与十进制相互转换
public class Main {
public static void main(String[] args){
String str = Long.toBinaryString(7);
System.out.println(str); // output: 111
long x = Long.parseLong("111", 2);
System.out.println(x); // output: 7
}
}
- 八进制与十进制相互转换
public class Main {
public static void main(String[] args){
String str = Long.toOctalString(63);
System.out.println(str); // output: 77
long x = Long.parseLong("77", 8);
System.out.println(x); // output: 31
}
}
- 十六进制与十进制相互转换
public class Main {
public static void main(String[] args){
String str = Long.toHexString(15);
System.out.println(str); // output: f
long x = Long.parseLong("1F", 16);
System.out.println(x); // output: 31
}
}
边栏推荐
猜你喜欢

Unsafe中的park和unpark

Xiaomi Interviewer: let's talk about the proficient Registration Center for three days and three nights

一個人管理1000臺服務器?這款自動化運維工具一定要掌握

OpenCV怎么下载?OpenCV下载后怎么配置?

Interviewer: please introduce cache penetration, cache null value, cache avalanche and cache breakdown, which are easy to understand

2022 cisp-pte (II) SQL injection

Machine learning

Meaning of 0.0.0.0:x

多表联查--07--- Hash join

用XGBoost迭代读取数据集
随机推荐
JDBC操作Mysql示例
Get the query parameter in the address URL specify the parameter method
【Kevin三连弹之三】Rust真的比C慢吗?进一步分析queen微测评
大学数据库mysql
【LeetCode】Day90-二叉搜索树中第K小的元素
Interviewer: please introduce cache penetration, cache null value, cache avalanche and cache breakdown, which are easy to understand
volatile 和 synchronized 到底啥区别?
Use uview to enable tabbar to display the corresponding number of tabbars according to permissions
面试官:用分库分表如何做到永不迁移数据和避免热点问题?
获取地址url中的query参数指定参数方法
Difference between boundvalueops and opsforvalue
Date database date strings are converted to and from each other
Hutool symmetric encryption
mssql如何使用语句导出并删除多表数据
poi导出excle
用XGBoost迭代读取数据集
How torch. gather works
JDBC事务提交事例
[graduation season] graduation is the new beginning of your life journey. Are you ready
Visual Studio VS 快捷键使用大全