On Thursday, 26 February 2015 at 11:17:12 UTC, Kingsley wrote:
Hardcoding the double[] does work as expected - so why doesn't it work with the iota generated array?

'double' represents a floating-point type with base 2.

This implies that decimal numbers like 0.1 (= 1/10 = 1/(2*5)) cannot be exactly represented using double. The double literal 0.1 refers to a number close to but not equal to the real number 0.1.

So when you use a literal step of 0.1 you actually use step 1.00000000000000005551115123126E-1.

The small error adds up in successive additions and, due to a finite number of digits, every addition can introduce further error.

Reply via email to