Float in loop | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
5th Aug 2019, 7:26 AM
UraL
3 Answers
+ 3
devanille really float:-)
5th Aug 2019, 7:11 PM
UraL
+ 2
Floating-point cannot represents fractional value perfectly. It can represents 1.0 perfectly, but if that 1.0 is the result of multiple additions, it may not perfect. If you try to change the print in that function to printf("d = %.20f\n", d); you'll see at some point that the value is slightly different than it should be
5th Aug 2019, 7:51 AM
Agent_I
Agent_I - avatar
0
Agent_I thanx for hint as "%.20f".
5th Aug 2019, 8:11 PM
UraL