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

浮点数转字符串没有四舍五入? #333

Open
cailei77 opened this issue Jul 16, 2023 · 3 comments
Open

浮点数转字符串没有四舍五入? #333

cailei77 opened this issue Jul 16, 2023 · 3 comments

Comments

@cailei77
Copy link

double f = 3.14159265;
fastring str;
str << dp::_n(f, 4);
cout << str << std::endl;
这段代码输出的结果是3.1415,按照精度要求应该是3.1416吧?

@youngday
Copy link

if we convert rad to degree, rang will over 180, 180.0004,
you can use round ,floor, or ceil ,before string conversion.

@cailei77
Copy link
Author

if we convert rad to degree, rang will over 180, 180.0004, you can use round ,floor, or ceil ,before string conversion.
我只是说浮点数转换为字符串的显示精度问题,计算精度应该不受影响

@idealvin
Copy link
Owner

double f = 3.14159265; fastring str; str << dp::_n(f, 4); cout << str << std::endl; 这段代码输出的结果是3.1415,按照精度要求应该是3.1416吧?

现在没有考虑四舍五入

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

3 participants