当前位置:网站首页>运算符<< >>傻瓜式测试用例
运算符<< >>傻瓜式测试用例
2022-07-04 06:18:00 【东西方集大成者】
千万要牢记: 左边是被操作数,右边是移动位数(这对左移符和右移符来说都是一样的)
public class Test {
// 从极限出发,傻瓜式测试
public static void main(String[] args) {
/*** 左移测试 ***/
// 被操作数 左移箭头 左移位数 二进制 十进制
System.out.println(1 << 0); // 1 向左移0位, 1 = 1
System.out.println(1 << 1); // 1 向左移1位, 10 = 2
System.out.println(1 << 2); // 1 向左移2位, 100 = 4
System.out.println(1 << 3); // 1 向左移3位, 1000 = 8
System.out.println(1 << 4); // 1 向左移4位,10000 = 16
System.out.println(2 << 1); // 2 向左移1位,10 变 100 即 4
System.out.println(2 << 2); // 2 向左移2位,10 变 1000 即 8
System.out.println(2 << 3); // 2 向左移3位,10 变 10000 即 16
System.out.println(2 << 4); // 2 向左移4位,10 变 100000 即 32
System.out.println(3 << 1); // 3 向左移1位,11 变 110 即 6
System.out.println(3 << 2); // 3 向左移2位,11 变 1100 即 12
System.out.println(3 << 3); // 3 向左移3位,11 变 11000 即 24
System.out.println(3 << 4); // 3 向左移4位,11 变 110000 即 48
/*** 右移测试 ***/
// 被操作数 右移箭头 右移位数 二进制 十进制
System.out.println(1 >> 0); // 1 向右移0位, 1 = 1
System.out.println(1 >> 1); // 1 向右移1位, 0 = 0
System.out.println(1 >> 2); // 1 向右移2位, 0 = 0
System.out.println(1 >> 3); // 1 向右移3位, 0 = 0
System.out.println(1 >> 4); // 1 向右移4位, 0 = 0
System.out.println(2 >> 0); // 2 向右移1位,10 变 10 即 2
System.out.println(2 >> 1); // 2 向右移1位,10 变 01 即 1
System.out.println(2 >> 2); // 2 向右移2位,10 变 00 即 0
System.out.println(2 >> 3); // 2 向右移3位,10 变 00 即 0
System.out.println(2 >> 4); // 2 向右移4位,10 变 00 即 0
System.out.println(3 >> 1); // 3 向右移1位,11 变 01 即 1
System.out.println(3 >> 2); // 3 向右移2位,11 变 00 即 0
System.out.println(3 >> 3); // 3 向右移3位,11 变 00 即 0
System.out.println(3 >> 4); // 3 向右移4位,11 变 00 即 0
}
}
边栏推荐
- Considerations for testing a website
- Component、Container容器常用API详解:Frame、Panel、ScrollPane
- 746. Climb stairs with minimum cost
- JS arguments parameter usage and explanation
- After the festival, a large number of people change careers. Is it still time to be 30? Listen to the experience of the past people
- Inputstream/outputstream (input and output of file)
- 云原生——上云必读之SSH篇(常用于远程登录云服务器)
- js如何将秒转换成时分秒显示
- Stc8h development (XII): I2C drive AT24C08, at24c32 series EEPROM storage
- JS get the attribute values nested in the object
猜你喜欢
740. Delete and get points
JS how to convert seconds into hours, minutes and seconds display
JS execution mechanism
Win10 clear quick access - leave no trace
【无标题】
gslb(global server load balance)技术的一点理解
C语言中的函数(详解)
配置交叉编译工具链和环境变量
Inputstream/outputstream (input and output of file)
4G wireless all network solar hydrological equipment power monitoring system bms110
随机推荐
ABAP:OOALV实现增删改查功能
安装 Pytorch geometric
C réaliser des jeux de serpents gourmands
198. House raiding
How to implement cross domain requests
How to help others effectively
Invalid revision: 3.18.1-g262b901-dirty
SQL join, left join, right join usage
JS execution mechanism
AWT introduction
Invalid bound statement (not found): com. example. mapper. TblUserRecordMapper. login
[March 3, 2019] MAC starts redis
High performance parallel programming and optimization | lesson 02 homework at home
Compound nonlinear feedback control (2)
冲击继电器JC-7/11/DC110V
px em rem的区别
Recommended system 1 --- framework
配置交叉编译工具链和环境变量
Average two numbers
如何获取el-tree中所有节点的父节点