gcd with doubles

Alex via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Aug 27 12:47:59 PDT 2017


Hi, all.
Can anybody explain to me why

void main()
{
	import std.numeric;
	assert(gcd(0.5,32) == 0.5);
	assert(gcd(0.2,32) == 0.2);
}

fails on the second assert?

I'm aware, that calculating gcd on doubles is not so obvios, as 
on integers. But if the library accepts doubles, and basically 
the return is correct occasionally, why it is not always the case?
Is there a workaround, maybe?


More information about the Digitalmars-d-learn mailing list