What am I doing wrong here - canFind with iota is not working
Fool via Digitalmars-d
digitalmars-d at puremagic.com
Thu Feb 26 03:48:28 PST 2015
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.
More information about the Digitalmars-d
mailing list