当前位置:网站首页>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
边栏推荐
- 力扣 1790. 仅执行一次字符串交换能否使两个字符串相等
- 强化学习-学习笔记8 | Q-learning
- MRS离线数据分析:通过Flink作业处理OBS数据
- Get webkitformboundary post login
- R language ggplot2 visualization: use the ggdensity function of ggpubr package to visualize the packet density graph, and use stat_ overlay_ normal_ The density function superimposes the positive dist
- Visual Studio 插件之CodeMaid自动整理代码
- Force buckle 1790 Can two strings be equal by performing string exchange only once
- 浅尝不辄止系列之试试腾讯云的TUIRoom(晚上有约,未完待续...)
- Force buckle 88 Merge two ordered arrays
- Mysql, sqlserver Oracle database connection mode
猜你喜欢
CIS芯片测试到底怎么测?
【STL】vector
开源重器!九章云极DataCanvas公司YLearn因果学习开源项目即将发布!
Chapter 9 Yunji datacanvas was rated as 36 krypton "the hard core technology enterprise most concerned by investors"
Force buckle 2319 Judge whether the matrix is an X matrix
国家网信办公布《数据出境安全评估办法》:累计向境外提供10万人信息需申报
多个线程之间如何协同
微信公众号OAuth2.0授权登录并显示用户信息
Compiler optimization (4): inductive variables
Leetcode force buckle (Sword finger offer 36-39) 36 Binary search tree and bidirectional linked list 37 Serialize binary tree 38 Arrangement of strings 39 Numbers that appear more than half of the tim
随机推荐
JVM 类加载机制
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
JVM GC garbage collection brief
gorilla官方:golang开websocket client的示例代码
数据孤岛是企业数字化转型遇到的第一道险关
c语言如何判定是32位系统还是64位系统
浅尝不辄止系列之试试腾讯云的TUIRoom(晚上有约,未完待续...)
Some important knowledge of MySQL
Leetcode force buckle (Sword finger offer 36-39) 36 Binary search tree and bidirectional linked list 37 Serialize binary tree 38 Arrangement of strings 39 Numbers that appear more than half of the tim
[auto.js] automatic script
力扣 1790. 仅执行一次字符串交换能否使两个字符串相等
开源OA开发平台:合同管理使用手册
力扣 643. 子数组最大平均数 I
Training IX basic configuration of network services
Classification automatique des cellules de modules photovoltaïques par défaut dans les images de lecture électronique - notes de lecture de thèse
Force buckle 599 Minimum index sum of two lists
Open source heavy ware! Chapter 9 the open source project of ylarn causal learning of Yunji datacanvas company will be released soon!
力扣 1232.缀点成线
ASP. Net learning & ASP's one word
sql 常用优化