Quote:
The problem is that result of successive incrementing of value
of variable k inside looop is incorrect :
k = 9,99999999999998 instead k = 10.
It is not incorrect.
0.1 is coded in binary floating point value, and you have to know that 0.1 coded in floating point value is not exact. This is the standard coding for c, C++ and C#.
To handle such values with exact coding, you have to specialized library.
One solution id to multiply everything by 10 and use integer and then divide by 10 when you want to display.
Floating point - Wikipedia, the free encyclopedia[
^]
C/FloatingPoint[
^]