当前位置:网站首页>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
- webscoket 数据库监听
- How to download opencv? How to configure opencv after downloading?
- Date database date strings are converted to and from each other
- Idea method template
- 语音信号处理-概念(四):傅里叶变换、短时傅里叶变换、小波变换
- View functions in tidb
- mssql如何使用语句导出并删除多表数据
- Tidb database Quick Start Guide
- 攻防演习防御体系构建之第二篇之应对攻击的常用策略
猜你喜欢
一个人管理1000台服务器?这款自动化运维工具一定要掌握
volatile 和 synchronized 到底啥区别?
Yarn create vite reports an error 'd:\program' which is neither an internal or external command nor a runnable program or batch file
Centos7.9 install MySQL 5.7 and set startup
MySQL
Xiaomi Interviewer: let's talk about the proficient Registration Center for three days and three nights
SQL injection bypass (I)
Matlab GUI interface simulation DC motor and AC motor speed simulation
2022 CISP-PTE(二)SQL注入
面试官:大量请求 Redis 不存在的数据,从而打倒数据库,你有什么方案?
随机推荐
SQL考勤查询间隔一小时
window右键管理
解决 Win10 Wsl2 IP 变化问题
JDBC参数化查询示例
(已解决) MINet 进行测试时报错如下 raise NotImplementedError
[leetcode] day90 the element with the smallest K in the binary search tree
POI export excle
The song of cactus -- throwing stones to ask the way (1)
mysql关于自增和不能为空
多表联查--07--- Hash join
OpenCV怎么下载?OpenCV下载后怎么配置?
高薪程序员&面试题精讲系列116之Redis缓存如何实现?怎么发现热key?缓存时可能存在哪些问题?
2022 CISP-PTE(二)SQL注入
通过uview让tabbar根据权限显示相应数量的tabbar
guava 教程收集一些案例慢慢写 google工具类
boundvalueops和opsforvalue区别
Solve the problem of win10 wsl2 IP change
专业四第二周自测
Window right click management
Rust Async: smol源码分析-Executor篇