could someone check this on another system?

BCS ao at pathlink.com
Tue May 5 10:09:24 PDT 2009


Reply to Kagamin,

> BCS Wrote:
> 
>> I've posted the code here:
>> 
>> http://smplsite.com/filebox/error.zip
>> 
> auto r = (rp == Point(-.5,1.5));
> writef("---%s\n", r);
> assert(r, "++"~rp.toString);
> Is this it?
> 


Yes that's the spot that was (is?) generating an error. I'm not so sure anymore 
as my system is no longer reproing but I seem to recall that it was printing 
out true inside the opEquals function but false outside.

BTW the first function in that file had a bug and should be:

//Usable AlmostEqual function
bool ULP(T)(T A, T B, uint maxUlps)
{
	if(A == B) return true;
	static if(is(T == float)) { alias int Tint; Tint bound = 0x8000_0000; }
	else static if(is(T == double)) { alias long Tint; Tint bound = 0x8000_0000_0000_0000; 
}
	else static assert(false, "only float or double can be used, not "~T.stringof);
		
	// Make sure maxUlps is non-negative and small enough that the
	// default NAN won't compare as equal to anything.
	assert(maxUlps > 0 && maxUlps < 4 * 1024 * 1024);

	auto aInt = *cast(Tint*)&A;
	// Make aInt lexicographically ordered as a twos-complement int
	if (aInt < 0) aInt = bound - aInt;

	// Make bInt lexicographically ordered as a twos-complement int
	auto bInt = *cast(Tint*)&B;
	if (bInt < 0) bInt = bound - bInt;

	auto ulp = abs(aInt - bInt); 
	if (ulp <= maxUlps) return true;
	return false;
}





More information about the Digitalmars-d mailing list