当前位置:网站首页>运算符<< >>傻瓜式测试用例
运算符<< >>傻瓜式测试用例
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
}
}
边栏推荐
- Uninstall Google drive hard drive - you must exit the program to uninstall
- 复合非线性反馈控制(二)
- Kubernets first meeting
- SQL join, left join, right join usage
- C realize Snake games
- How to implement lazy loading in El select (with search function)
- Considerations for testing a website
- Fast power (template)
- Component、Container容器常用API详解:Frame、Panel、ScrollPane
- Invalid revision: 3.18.1-g262b901-dirty
猜你喜欢

How to realize multi account login of video platform members

Gridview出现滚动条,组件冲突,如何解决

Layoutmanager layout manager: flowlayout, borderlayout, GridLayout, gridbaglayout, CardLayout, BoxLayout
![[microservice] Nacos cluster building and loading file configuration](/img/50/7af220c57a06eb186729c9882d9dab.png)
[microservice] Nacos cluster building and loading file configuration

Learn about the Internet of things protocol WiFi ZigBee Bluetooth, etc. --- WiFi and WiFi protocols start from WiFi. What do we need to know about WiFi protocol itself?

C實現貪吃蛇小遊戲

C语言中的函数(详解)

【无标题】

JSON Web Token----JWT和传统session登录认证对比

How to choose the middle-aged crisis of the testing post? Stick to it or find another way out? See below
随机推荐
JSON Web Token----JWT和传统session登录认证对比
Nexus 6p downgraded from 8.0 to 6.0+root
px em rem的区别
Learn about the Internet of things protocol WiFi ZigBee Bluetooth, etc. --- WiFi and WiFi protocols start from WiFi. What do we need to know about WiFi protocol itself?
"In simple language programming competition (basic)" part 1 Introduction to language Chapter 3 branch structure programming
Bicolor case
Detectron:训练自己的数据集——将自己的数据格式转换成COCO格式
[microservice] Nacos cluster building and loading file configuration
R统计绘图-随机森林分类分析及物种丰度差异检验组合图
2022.7.2-----leetcode. eight hundred and seventy-one
Install pytoch geometric
FRP intranet penetration, reverse proxy
QT QTableWidget 表格列置顶需求的思路和代码
Impact relay jc-7/11/dc110v
Nexus 6p从8.0降级6.0+root
微信小程序使用rich-text中图片宽度超出问题
2022.7.3-----leetcode.556
Detectron: train your own data set -- convert your own data format to coco format
C language - Blue Bridge Cup - Snake filling
C语言中的函数(详解)