Code results in 1, but supposed to be .999991

I believe the following code may have been written erroneously. The comment states ‘Adding 0.001 for a thousand times’. But the code is actually ‘Adding 0.1 for ten times’ which returns 1. Great course on D by the way! Cheers! :slight_smile:

// Adding 0.001 for a thousand times:

    int counter = 1;

    while (counter <= 10) {

        result += 0.1;



Type your question above this line.


Hello @Gary_Chike

Thank you for pointing out the typo. User feedback is very valuable for us and helps us to improve our content. The code snippet has been updated now according to the description.


1 Like