常用备忘录
记录经常不太记得,需要查询的细节知识
运算符优先级
- 括号:
() - 幂运算:
** - 一元运算符:
+x,-x,~x - 乘除取余:
*,/,%,// - 加减:
+,- - 位移:
<<,>> - 按位与:
& - 按位异或:
^ - 按位或:
| - 比较:
==,!=,>,<,>=,<=,is,is not,in,not in - 逻辑与:
and - 逻辑或:
or - 条件表达式:
if…else - 赋值:
=,+=,-=,*=,/=,%=,//=,**=,&=,|=,^=,>>=,<<= - 逗号:
,
数字类型和格式化符号
数字类型
整数类型
标准整数
int: 默认整数类型,大小取决于系统架构 (32位或64位)。uint: 无符号整数。
特定大小整数
- 有符号整数:
int8: 8位有符号整数 (-128 到 127)int16: 16位有符号整数 (-32,768 到 32,767)int32: 32位有符号整数 (-2,147,483,648 到 2,147,483,647)int64: 64位有符号整数 (-9,223,372,036,854,775,808 到 9,223,372,036,854,775,807)
- 无符号整数:
uint8: 8位无符号整数 (0 到 255)uint16: 16位无符号整数 (0 到 65,535)uint32: 32位无符号整数 (0 到 4,294,967,295)uint64: 64位无符号整数 (0 到 18,446,744,073,709,551,615)
- 有符号整数:
浮点数类型
float32: 32位浮点数float64: 64位浮点数 (双精度)
其他类型
- 复数:
complex64(实部和虚部为float32),complex128(实部和虚部为float64) - 布尔:
bool(True,False) - 字节:
byte(uint8的别名)
C语言格式化符号
整数类型
int:%d,%i(有符号整数)unsigned int:%u(无符号整数)short:%hd(有符号短整数)unsigned short:%hu(无符号短整数)long:%ld(有符号长整数)unsigned long:%lu(无符号长整数)long long:%lld(有符号长长整数)unsigned long long:%llu(无符号长长整数)int8_t/uint8_t:%d/%u(有符号/无符号8位整数)int16_t/uint16_t:%d/%u(有符号/无符号16位整数)int32_t/uint32_t:%d/%u(有符号/无符号32位整数)int64_t/uint64_t:%lld/%llu(有符号/无符号64位整数)
浮点数类型
float:%f(浮点数)double:%lf(双精度浮点数)long double:%Lf(长双精度浮点数)- 科学计数法:
%e,%E
字符和字符串
char:%c(字符)char[]:%s(字符串)
指针
- 指针地址:
%p
其他格式化符号
- 十六进制:
%x(小写),%X(大写) - 八进制:
%o
github代理
1git config --get http.proxy
2git config --get https.proxy
3git config --global http.proxy http://username:password@proxyserver:port
4git config --global https.proxy https://username:password@proxyserver:port
5git config --global http.proxy socks5://127.0.0.1:10808
6git config --global https.proxy socks5://127.0.0.1:10808
7git config --global --unset http.proxy
8git config --global --unset https.proxy
windows下可以手动刷新dns缓存:
1ipconfig /flushdns
github在windows下ssh的22端口无法使用,可以修改.ssh文件夹中的config文件
1Host github.com
2 Hostname ssh.github.com
3 Port 443
32位和64位系统
32位和64位系统在数据类型的字节数上主要的区别在于指针和长整型(long)的大小。其他数据类型(如char、int、float等)的大小通常在32位和64位系统上保持不变。下面是32位和64位系统上常见数据类型的字节数:
常见数据类型在32位和64位系统上的字节数
| 数据类型 | 32位系统 (x86) | 64位系统 (x64) |
|---|---|---|
char | 1 字节 | 1 字节 |
short | 2 字节 | 2 字节 |
int | 4 字节 | 4 字节 |
float | 4 字节 | 4 字节 |
double | 8 字节 | 8 字节 |
long | 4 字节 | 8 字节 (在一些系统上,如 Linux) |
long long | 8 字节 | 8 字节 |
void* (指针) | 4 字节 | 8 字节 |
size_t | 4 字节 | 8 字节 |
主要区别
指针 (
void*):- 在32位系统上,指针的大小为4字节,因为32位系统的地址空间是32位。
- 在64位系统上,指针的大小为8字节,因为64位系统的地址空间是64位。
长整型 (
long):long的大小在32位系统上通常是4字节。- 在64位系统上,
long的大小有时是4字节(如在Windows上),有时是8字节(如在大多数Unix和Linux系统上),这取决于编译器和平台。
其他类型:
- 数据类型如
char、short、int、float和double的大小通常在32位和64位系统上是相同的。
- 数据类型如
例外情况
不同的操作系统和编译器可能会有不同的规定。例如:
- 在Windows 64位系统上,
long类型仍然是4字节。 - 在Linux 64位系统上,
long类型是8字节。
在学习正运动学和逆运动学时,三角函数是非常重要的数学工具。以下是一些常用的三角函数值和常见参数:
1. 常见角度的三角函数值
| 角度(°) | 角度(弧度) | sin | cos | tan | cot |
|---|---|---|---|---|---|
| 0° | 0 | 0 | 1 | 0 | 不存在 |
| 30° | π/6 | 1/2 | √3/2 | 1/√3 | √3 |
| 45° | π/4 | √2/2 | √2/2 | 1 | 1 |
| 60° | π/3 | √3/2 | 1/2 | √3 | 1/√3 |
| 90° | π/2 | 1 | 0 | 不存在 | 0 |
| 180° | π | 0 | -1 | 0 | 不存在 |
| 270° | 3π/2 | -1 | 0 | 不存在 | 0 |
| 360° | 2π | 0 | 1 | 0 | 不存在 |
备注:
- tan(90°) 和 tan(270°) 不存在(趋向无穷)。
- cot(0°)、cot(180°)、cot(360°) 不存在(趋向无穷)。
2. 常用三角函数公式
基本恒等式
- $$ ( \sin^2 \theta + \cos^2 \theta = 1 ) $$
- $$ (1 + \tan^2 \theta = \frac{1}{\cos^2 \theta} ) $$
- $$ (1 + \cot^2 \theta = \frac{1}{\sin^2 \theta} ) $$
两角和与差公式
- $$ (\sin(A \pm B) = \sin A \cos B \pm \cos A \sin B ) $$
- $$ (\cos(A \pm B) = \cos A \cos B \mp \sin A \sin B ) $$
- $$ (\tan(A \pm B) = \frac{\tan A \pm \tan B}{1 \mp \tan A \tan B} ) $$
倍角公式
- $$ (\sin 2A = 2 \sin A \cos A ) $$
- $$ (\cos 2A = \cos^2 A - \sin^2 A = 2\cos^2 A - 1 = 1 - 2\sin^2 A ) $$
- $$ (\tan 2A = \frac{2\tan A}{1 - \tan^2 A} ) $$
半角公式
- $$ (\sin \frac{A}{2} = \pm \sqrt{\frac{1 - \cos A}{2}} ) $$
- $$ (\cos \frac{A}{2} = \pm \sqrt{\frac{1 + \cos A}{2}} ) $$
- $$ (\tan \frac{A}{2} = \pm \sqrt{\frac{1 - \cos A}{1 + \cos A}} = \frac{\sin A}{1 + \cos A} = \frac{1 - \cos A}{\sin A} ) $$
正弦定理与余弦定理
正弦定理: $$ [ \frac{a}{\sin A} = \frac{b}{\sin B} = \frac{c}{\sin C} = 2R ] $$ 其中 $$ (R ) $$为外接圆半径。
余弦定理: $$ [ c^2 = a^2 + b^2 - 2ab \cos C ] $$ 适用于任意三角形。
最后修改于 2025-03-25 14:33