# 附录\*进制转换

* **二进制：**&#x53EA;有0和1两个数字，基数为2，在加减法运算中，逢二进一，借一当二。
* **八进制：**&#x6709;0\~7共8个数字，基数为8，逢八进一，借一当八；
* **十进制：**&#x6709; 0\~9 共十个数字，逢十进一；
* **十六进制：**&#x7528;A来表示10，B表示11，C表示12，D表示13，E表示14，F表示15，因此有0\~F共16个数字，基数为16，逢16进1，借1当16。

例如：

* 二进制 1101 = 1×23 + 1×22 + 0×21 + 1×20 = 8 + 4 + 0 + 1 = 13
* 十进制 4321 = 4×103 + 3×102 + 2×101 + 1×100
* 八进制 3072 = 3×83 + 0×82 + 7×81 + 2×80 = 1536 + 0 + 56 + 2 = 1594
* 十六进制 E3F9 = 14×163 + 3×162 + 15×161 + 9×160 = 57344 + 768 + 240 + 9 = 58361

**二进制、八进制、十进制、十六进制的对应关系**

| 十进制 | 二进制  | 八进制 | 十六进制 | 十进制 | 二进制   | 八进制 | 十六进制 |
| --- | ---- | --- | ---- | --- | ----- | --- | ---- |
| 0   | 0    | 0   | 0    | 10  | 1010  | 12  | A    |
| 1   | 1    | 1   | 1    | 11  | 1011  | 13  | B    |
| 2   | 10   | 2   | 2    | 12  | 1100  | 14  | C    |
| 3   | 11   | 3   | 3    | 13  | 1101  | 15  | D    |
| 4   | 100  | 4   | 4    | 14  | 1110  | 16  | E    |
| 5   | 101  | 5   | 5    | 15  | 1111  | 17  | F    |
| 6   | 110  | 6   | 6    | 16  | 10000 | 20  | 10   |
| 7   | 111  | 7   | 7    | 17  | 10001 | 21  | 11   |
| 8   | 1000 | 10  | 8    | 18  | 10010 | 22  | 12   |
| 9   | 1001 | 11  | 9    | 19  | 10011 | 23  | 13   |

> 在C语言中，八进制通常以“0”开头（注意是数字 0，而不是字母 o），例如 0307；十六进制通常以“0x”或“0X”开头（不区分大小写），例如 0xE27 或 0X89F。

## 资料

[进制之间的转换](http://c.biancheng.net/cpp/html/2855.html)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://xiaoxiami.gitbook.io/c/jin-zhi-zhuan-huan.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
