> For the complete documentation index, see [llms.txt](https://docs.1l.lol/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.1l.lol/basics/units.md).

# 单位

### 数据存储单位

* **最小单位：比特（bit）**，取值 0 或 1
* **基本单位：字节（Byte）**，`1 Byte = 8 bit`
* 一个英文字符占 1 字节，一个汉字（UTF-8）通常占 3 字节

### 单位换算

| 单位   | 换算      |
| ---- | ------- |
| 1 B  | 8 bit   |
| 1 KB | 1024 B  |
| 1 MB | 1024 KB |
| 1 GB | 1024 MB |
| 1 TB | 1024 GB |

> 注意：内存/文件大小按 **1024** 进制；硬盘厂商常用 1000 进制，所以标称容量与系统显示会有差异。

### 与 C++ 类型的关系

| 类型        | 常见字节数 |
| --------- | ----- |
| char      | 1     |
| int       | 4     |
| long long | 8     |
| float     | 4     |
| double    | 8     |
| bool      | 1     |

### n 位二进制能表示的范围

* 无符号：`0 ~ 2^n - 1`
* 有符号（补码）：`-2^(n-1) ~ 2^(n-1) - 1`

例如 8 位有符号整数范围是 `-128 ~ 127`，32 位 int 范围约 `-2.1×10⁹ ~ 2.1×10⁹`。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.1l.lol/basics/units.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
