> 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/operator-precedence.md).

# 运算符优先级

| 优先级 | 运算符类别 | 具体运算符                                                                            | 结合性  | 说明            |       |               |
| --- | ----- | -------------------------------------------------------------------------------- | ---- | ------------- | ----- | ------------- |
| 1   | 最高优先级 | `()` (括号)、`[]` (下标)、`.` (成员访问)、`->` (指针成员访问)                                     | 从左到右 | 括号优先改变运算顺序    |       |               |
| 2   | 一元运算符 | `!` (非)、`~` (按位非)、`++`/`--` (自增 / 自减)、`+`/`-` (正负号)、`*` (解引用)、`&` (取地址)、`sizeof` | 从右到左 | 仅作用于单个操作数     |       |               |
| 3   | 算术乘除模 | `*` (乘)、`/` (除)、`%` (取模)                                                         | 从左到右 | 乘除模优先级高于加减    |       |               |
| 4   | 算术加减  | `+` (加)、`-` (减)                                                                  | 从左到右 |               |       |               |
| 5   | 移位运算符 | `<<` (左移)、`>>` (右移)                                                              | 从左到右 | 二进制位操作        |       |               |
| 6   | 关系运算符 | `<`、`<=`、`>`、`>=`                                                                | 从左到右 | 比较大小，返回布尔值    |       |               |
| 7   | 相等运算符 | `==` (等于)、`!=` (不等于)                                                             | 从左到右 | 注意区分`==`和`=`  |       |               |
| 8   | 按位与   | `&`                                                                              | 从左到右 | 二进制位与         |       |               |
| 9   | 按位异或  | `^`                                                                              | 从左到右 | 二进制位异或        |       |               |
| 10  | 按位或   | \`                                                                               | \`   | 从左到右          | 二进制位或 |               |
| 11  | 逻辑与   | `&&`                                                                             | 从左到右 | 短路求值（左假则右不执行） |       |               |
| 12  | 逻辑或   | \`                                                                               |      | \`            | 从左到右  | 短路求值（左真则右不执行） |
| 13  | 三目运算符 | `?:`                                                                             | 从右到左 | 唯一的三目运算符      |       |               |
| 14  | 赋值运算符 | `=`、`+=`、`-=`、`*=`、`/=`、`%=`、`<<=`、`>>=`、`&=`、`^=`、\`                            | =\`  | 从右到左          | 赋值操作  |               |
| 15  | 逗号运算符 | `,`                                                                              | 从左到右 | 分隔表达式，取最后一个值  |       |               |


---

# 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/operator-precedence.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.
