Skip to content

Commit

Permalink
Merge pull request #57 from QSCTech-Sange/main
Browse files Browse the repository at this point in the history
fix: cpp_tricks 中地板除的数字错误typo
  • Loading branch information
archibate authored Oct 18, 2024
2 parents 0dd85de + 97a9865 commit 010c93a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/cpp_tricks.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ std::wstring utf8_to_wstring(std::string const &s) {

```cpp
int a = 14, b = 5;
int c = a / b; // c = 14 / 5 = 3
int c = a / b; // c = 14 / 5 = 2
```

等价于

```cpp
int c = floor((float)a / b); // c = floor(2.8) = 3
int c = floor((float)a / b); // c = floor(2.8) = 2
```

如果 `a` 除以 `b` 除不尽,那么会找到比他大的第一个整数作为结果,这就是**地板除 (floor div)**
Expand Down

0 comments on commit 010c93a

Please sign in to comment.