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

四舍五入的精度问题 #125

Open
suishou opened this issue Sep 28, 2024 · 3 comments
Open

四舍五入的精度问题 #125

suishou opened this issue Sep 28, 2024 · 3 comments

Comments

@suishou
Copy link

suishou commented Sep 28, 2024

C++的浮点数精度是四舍五入的,python中round是银行家舍入,对于5时的处理策略是不一样的,能否处理一下呢

@Mr-Python-in-China
Copy link
Collaborator

哈 这项目里哪里用 round

@weilycoder
Copy link
Contributor

weilycoder commented Sep 30, 2024

你意思是加一个 C++ 风格的 round?我觉得不如手写一个 special judge(或者你最好保证精确答案 $\pm 10^{-6}$ 进行四舍五入或银行家舍入的结果一致),而且 C++ 的 cout 似乎也是银行家舍入。

@StevenJinyanCheng
Copy link

C++ round 到整数可以是 int(f+0.5)

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

4 participants