首页 技术 正文
技术 2022年11月7日
0 收藏 324 点赞 349 浏览 871 个字
public static void main(String[] args) {
long serverId = 65535;
System.out.println("ServerId:" + serverId);
long a1 = 0b11110001001000000;// 123456
// 11110001001000000
//
System.out.println("顺序号,a1:" + a1);
long a2 = a1 << 16;
System.out.println("左移16位,a2:" + a2);
// 11110001001000000 0000000000000000 //8090812416
// 00000000000000000 1111111111111111 //65535
// 11110001001000000 1111111111111111 //
long a3 = a2 | serverId;// 加入ServerId
System.out.println("加入ServerId,a3:" + a3); long a4 = a3 >> 16;
System.out.println("还原顺序号,a4:" + a4);
// 11110001001000000 1111111111111111 //8090877951
// 00000000000000001 1110001001000000 // long a5 = a3 & 65535;
System.out.println("还原ServerId,a5:" + a5);
// 11110001001000000 1111111111111111 //8090877951
// 00000000000000000 1111111111111111 //65535
// 两个位都为1时输出1,否则0
// 00000000000000000 1111111111111111 //
}

输出结果:

ServerId:65535
顺序号,a1:123456
左移16位,a2:8090812416
加入ServerId,a3:8090877951
还原顺序号,a4:123456
还原ServerId,a5:65535
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,104
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,580
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,428
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,200
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,835
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,918