当前位置:网站首页>Splicing and splitting of integer ints
Splicing and splitting of integer ints
2022-07-07 20:11:00 【junxuezheng】
Here's the catalog title
One 、int Splicing and splitting of
1. Split
- int Data types occupy 32 position .
- Split into high 30 Bit and low 2 position , In fact, it's a 32 The height of a bit 30 Bit and low 2 Bit data is taken out .
- for example int a =14
- a Stored hex :0x0000 000E
- a Stored binary :0000 0000 0000 0000 | 0000 0000 0000 1110
- a Split height 30 Is it :( Binary system )0000 0000 0000 0000 | 0000 0000 0000 11, The conversion 10 Into the system for 3
- a Split low 2 Is it :( Binary system )10, Convert to decimal to 2.
2. Splicing
The order of splicing and splitting is reversed ,
Simply put, put the data a The height of 30 Bit shift left 2 position ( Binary system 0000 0000 0000 0000 | 0000 0000 0000 11),
Then add low 2 A data ( Binary system 10)
Two 、c++ demo
#include <iostream>
using namespace std;
int main()
{
int a = 14;
// hold int a Split into left 30 position , Right 2 position
int a_left = (a & 0xfffffffc) >> 2;
int a_right = (a & 0xfffffff3);
// Merge
int a_ori = (a_left << 2) + a_right;
std::cout << "a_left="<<a_left<<endl;
std::cout << "a_left=" << a_right << endl;
std::cout << "a_ori=" << a_ori << endl;
}
Output
a_left=3
a_left=2
a_ori=14
Reference resources :
C++ Operator takes two 32 Digit splicing 64 digit
边栏推荐
- With st7008, the Bluetooth test is completely grasped
- Interpretation of transpose convolution theory (input-output size analysis)
- pom.xml 配置文件标签:dependencies 和 dependencyManagement 区别
- ASP. Net kindergarten chain management system source code
- rk3128投影仪lcd显示四周显示不完整解决
- Graduation season | regretful and lucky graduation season
- Force buckle 2319 Judge whether the matrix is an X matrix
- BI的边界:BI不适合做什么?主数据、MarTech?该如何扩展?
- Some arrangements about oneself
- Visual Studio 插件之CodeMaid自动整理代码
猜你喜欢
Yolov6:yolov6+win10--- train your own dataset
CIS芯片测试到底怎么测?
Interpretation of transpose convolution theory (input-output size analysis)
With st7008, the Bluetooth test is completely grasped
BI的边界:BI不适合做什么?主数据、MarTech?该如何扩展?
Automatic classification of defective photovoltaic module cells in electroluminescence images-論文閱讀筆記
LeetCode_ 7_ five
国家网信办公布《数据出境安全评估办法》:累计向境外提供10万人信息需申报
力扣 2319. 判断矩阵是否是一个 X 矩阵
机器学习笔记 - 使用Streamlit探索对象检测数据集
随机推荐
[auto.js] automatic script
力扣 989. 数组形式的整数加法
Force buckle 643 Subarray maximum average I
关于cv2.dnn.readNetFromONNX(path)就报ERROR during processing node with 3 inputs and 1 outputs的解决过程【独家发布】
pom.xml 配置文件标签作用简述
mysql 的一些重要知识
Traversée des procédures stockées Oracle
[sword finger offer] sword finger offer II 012 The sum of left and right subarrays is equal
力扣 459. 重复的子字符串
vulnhub之tre1
第二十章 使用工作队列管理器(三)
浅尝不辄止系列之试试腾讯云的TUIRoom(晚上有约,未完待续...)
torch. nn. functional. Pad (input, pad, mode= 'constant', value=none) record
Kubernetes -- detailed usage of kubectl command line tool
How to test CIS chip?
九章云极DataCanvas公司获评36氪「最受投资人关注的硬核科技企业」
Flink并行度和Slot详解
Traversal of Oracle stored procedures
Sword finger offer II 013 Sum of two-dimensional submatrix
机器学习笔记 - 使用Streamlit探索对象检测数据集