当前位置:网站首页>Binary complement
Binary complement
2022-07-25 15:28:00 【Don't stop laughing】
I just came across a problem , seek b Value
byte b = (byte)129;
Just got the question , Let's take a look. , Ah , Isn't this forced type conversion ?byte It's symbolic , So we began to calculate :
byte A byte , That is to say 8 Bit binary that 129 Namely :10000001
At first glance, it is symbolic , That is, the sign bit remains unchanged , Other positions are inverted +1:11111110+1=11111111=-127(1+2+4+8+16+32+64)
balabala~ It's been a long time , Half an hour passed , So is there a better way ?
We know ,byte Is a signed single byte integer , So the range of stored numbers is [-128·127], Complement should be calculated as above . But why should we calculate like this ?
Because scientists define numbers as a ring , The largest number is followed by the smallest , In this way, we can [0·255] Assigned to [-128·127].
The bottom layer is the concept of complement .
So let's count ,129 Greater than byte Express the largest integer 127. And it's a ring , That's it 127 After that is byte The smallest negative number -128,-127 . OK, it's -127 了 , That's it . Is it a matter of minutes ?
边栏推荐
- Word 样式模板复制到另一文档
- 带你创建你的第一个C#程序(建议收藏)
- The number of query results of maxcompute SQL is limited to 1W
- JVM parameter configuration details
- 带你详细认识JS基础语法(建议收藏)
- GAMES101复习:三维变换
- No tracked branch configured for branch xxx or the branch doesn‘t exist. To make your branch trac
- matlab 如何保存所有运行后的数据
- Take you to learn more about JS basic grammar (recommended Collection)
- ICPC2021昆明M-暴力+主席树
猜你喜欢
随机推荐
ML - 图像 - 深度学习和卷积神经网络
PAT甲级1153 Decode Registration Card of PAT (25 分)
自定义注解校验API参数电话号
UIDocumentInteractionController UIDocumentPickerViewController
Notes on inputview and inputaccessoryview of uitextfield
2019浙江省赛C-错排问题,贪心
PAT甲级1152 Google Recruitment (20 分)
JVM-垃圾收集器详解
C#精挑整理知识要点10 泛型(建议收藏)
Spark提交参数--files的使用
C # fine sorting knowledge points 10 generic (recommended Collection)
Understanding the execution order of T-SQL query from the execution order of join on and where
Args parameter parsing
GAMES101复习:变换
BPSK调制系统MATLAB仿真实现(1)
Distributed principle - what is a distributed system
4PAM在高斯信道与瑞利信道下的基带仿真系统实验
Flink-1.13.6版本的 Flink sql以yarn session 模式运行,怎么禁用托管
Spark AQE
Run redis on docker to start in the form of configuration file, and the connection client reports an error: server closed the connection









