当前位置:网站首页>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
边栏推荐
- Simulate the implementation of string class
- JVM GC garbage collection brief
- 力扣 1037.有效的回旋镖
- Opencv learning notes high dynamic range (HDR) imaging
- 力扣 2315.统计星号
- 毕业季|遗憾而又幸运的毕业季
- pom. Brief introduction of XML configuration file label function
- R language ggplot2 visualization: use the ggviolin function of ggpubr package to visualize the violin diagram, set the palette parameter to customize the filling color of violin diagrams at different
- R language uses ggplot2 function to visualize the histogram distribution of counting target variables that need to build Poisson regression model, and analyzes the feasibility of building Poisson regr
- 剑指 Offer II 013. 二维子矩阵的和
猜你喜欢
YoloV6:YoloV6+Win10---训练自己得数据集
LeetCode_ 7_ five
vulnhub之Funfox2
关于cv2.dnn.readNetFromONNX(path)就报ERROR during processing node with 3 inputs and 1 outputs的解决过程【独家发布】
Compiler optimization (4): inductive variables
Classification automatique des cellules de modules photovoltaïques par défaut dans les images de lecture électronique - notes de lecture de thèse
【mysql篇-基础篇】事务
openEuler 有奖捉虫活动,来参与一下?
Open source heavy ware! Chapter 9 the open source project of ylarn causal learning of Yunji datacanvas company will be released soon!
Opencv学习笔记 高动态范围 (HDR) 成像
随机推荐
JVM 类加载机制
Force buckle 1037 Effective boomerang
Force buckle 989 Integer addition in array form
数据孤岛是企业数字化转型遇到的第一道险关
【STL】vector
多个线程之间如何协同
c语言如何判定是32位系统还是64位系统
sql 常用优化
Kubernetes -- detailed usage of kubectl command line tool
线性基
pom. XML configuration file label: differences between dependencies and dependencymanagement
Opencv learning notes high dynamic range (HDR) imaging
干货分享|DevExpress v22.1原版帮助文档下载集合
pom.xml 配置文件标签作用简述
How to cooperate among multiple threads
Interpretation of transpose convolution theory (input-output size analysis)
一文读懂数仓中的pg_stat
YoloV6:YoloV6+Win10---训练自己得数据集
R language ggplot2 visualization: use the ggqqplot function of ggpubr package to visualize the QQ graph (Quantitative quantitative plot)
力扣 912.排序数组