0

I seem to have an issue adding float numbers in c++.

Im trying to calculate eulers number but when i try to add the float numbers it wont let me. My code: https://code.sololearn.com/crlhy7DTqjVi/?ref=app https://code.sololearn.com/crlhy7DTqjVi/?ref=app

23rd Jul 2022, 8:59 PM
Cristobal Rabah
4 Answers
+ 3
23rd Jul 2022, 9:09 PM
Slick
Slick - avatar
+ 2
To adjust decimal points, use `setprecision` from <iomanip> http://cplusplus.com/reference/iomanip/setprecision/
23rd Jul 2022, 11:49 PM
Ipang
+ 1
Because s is an integer. s would need to be a float for that.
23rd Jul 2022, 9:13 PM
Felix Alcor
Felix Alcor - avatar
0
Slick Felix Alcor thanks a lot guys, that worked. Any idea why it wont go past the 5th decimal point? I even tried long double.
23rd Jul 2022, 11:06 PM
Cristobal Rabah