§2 信息的表示和处理

type
status
date
slug
summary
tags
category
icon
password

§2.1 位、整数

§2.1.1 信息的位表示

位/bit/b:0或1
字节/B:8 bit
字:计算机32/64位,CPU中ALU的数据位数=CPU中通用寄存器的位数,汇编语言16位
C 数据类型
32位
64位
x86-64
char
1
1
1
short
2
2
2
int
4
4
4
long
4
8
8
long long
8
8
8
float
4
4
4
double
8
8
8
long double
−/12
−/16
10/16
pointer
4
8
8

§2.1.2 位级运算

与&、或|、非~、异或^
左移、右移(逻辑右移、算术右移:复制左边最高位)

§2.1.3 整型数

  1. 表示:无符号数和有符号数
二进制B
十六进制H(1、2、3、4、5、6、7、8、9、A、B、C、D、E、F)
10 11 12 13 14 15
notion image
进制转换:整数除基取余法、小数乘基取余法
原码、反码、补码
notion image
  1. 无符号数和有符号数的转换
notion image
notion image
notion image
sizeof()是无符号数
  1. 扩展、截断
符号扩展:有符号数复制最高有效位,无符号数高位补0
符号截断:直接截断
  1. 整数运算:加、非、乘、移位
无符号数加法
notion image
补码加法
notion image
  1. 总结

§2.1.4 内存、指针、字符串表示

大端序:最低有效位字节的地址最高
小端序:最低有效位字节的地址最低
notion image

期末真题

24春
notion image
1000 0000 0000 0000 0000 0000 0000 1010
FF FF FF F6
F6 FF FF FF
23春
notion image
A
原码:1000 0000 0000 0011
反码:1111 1111 1111 1100
补码:1111 1111 1111 1101
小端序:1101 1111 1111 1111 FF
notion image
B
notion image
FFA9
notion image
22春
notion image
歧义
21春
notion image
B
notion image
×
notion image

§2.2 浮点数

§2.2.1 二进制小数

右移/2,左移*2

§2.2.2 IEEE浮点数标准:IEEE 754

notion image
notion image
notion image
notion image
notion image
notion image
notion image
notion image
notion image

§2.2.3 浮点数示例与性质

notion image

§2.2.4 舍入、加法与乘法

notion image

§2.2.5 C语言的浮点数

期末真题

24春
notion image
B
notion image
notion image
notion image
23春
notion image
0xBFC00000
1|0111 1111|1000…
1011 1111 1100…
22春
notion image
×
notion image

§2.3 字与串

§2.3.1 非数值型数据

§2.3.2 英文字符编码

ASCII编码

§2.3.3 汉字编码

UTF-8
notion image
notion image
Loading...