当前位置:网站首页>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
}
}
边栏推荐
- Date database date strings are converted to and from each other
- How torch. gather works
- JDBC操作Mysql示例
- R 语言Analyzing wine data
- Easyexcel: read Excel data into the list set
- Interviewer: do you have any plan to request a lot of data that does not exist in redis to destroy the database?
- Window right click management
- guava 定时任务
- JDBC operation MySQL example
- 程序人生 - 程序员三十五岁瓶颈你怎么看?
猜你喜欢

vs怎么配置OpenCV?2022vs配置OpenCV详解(多图)

从5秒优化到1秒,系统飞起来了...

win10远程连接云服务器

程序人生 - 程序员三十五岁瓶颈你怎么看?

Rust Async: smol源码分析-Executor篇

【编译原理】山东大学编译原理复习提纲

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

Interviewer: do you have any plan to request a lot of data that does not exist in redis to destroy the database?

Interviewer: you use Lombok every day. What is its principle? I can't answer

Configuring FTP, enterprise official website, database and other methods for ECS
随机推荐
正斜杠反斜杠的由来
面试官:请你介绍一下缓存穿透、缓存空值、缓存雪崩、缓存击穿的,通俗易懂
Visual studio vs shortcut key usage
uview的安装和功能
Bean拷贝详解
How to download opencv? How to configure opencv after downloading?
Rust中的Pin详解
云服务器配置ftp、企业官网、数据库等方法
Use uview to enable tabbar to display the corresponding number of tabbars according to permissions
Easyexcel: read Excel data into the list set
DMU software syntax highlighting VIM setting -- Learning Notes 6
OPPO面试整理,真正的八股文,狂虐面试官
Idea方法模板
Transaction overview of tidb
高薪程序员&面试题精讲系列116之Redis缓存如何实现?怎么发现热key?缓存时可能存在哪些问题?
Idea method template
Xiaomi Interviewer: let's talk about the proficient Registration Center for three days and three nights
Origin of forward slash and backslash
View functions in tidb
Yarn create vite reports an error 'd:\program' which is neither an internal or external command nor a runnable program or batch file