Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C语言默认应该是截断除法 #81

Open
CKCat opened this issue Jan 17, 2025 · 0 comments
Open

C语言默认应该是截断除法 #81

CKCat opened this issue Jan 17, 2025 · 0 comments

Comments

@CKCat
Copy link

CKCat commented Jan 17, 2025

https://parallel101.github.io/cppguidebook/cpp_tricks/ 地板除与天花板除中描述C 语言默认的就是地板除。

这里的描述应该有问题吧,c语言的除法应该是截断除法(Truncated Division)。。

7/3 = 2
-7/3 = -2

python 整除默认的是地板除法。

7//3 = 2
-7//3 = -3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant