Subject: Re: accuracy of "long double"
To: None <firstname.lastname@example.org>
From: Neil Booth <email@example.com>
Date: 08/30/2007 07:29:34
>> Yes, no, yes. :) Rounding for all FP arithmetic is to double precision
>> by default.
> That's still (partially) unclear. You mean that, if I add two
> <long double>s and put the result in a <long double>, I won't
> get the extra precision I expect in the result because it will
> be truncated to (normal) <double> precision ?
Yes. You can test this yourself of course:
volatile double y = DBL_EPSILON;
volatile long double z = LDBL_EPSILON;
int main (void)
return (z > 0 && z + 1 == 1
&& y > 0 && y + 1 != 1);
For me on NetBSD main returns 1. Which makes me wonder whether
the definition of LDBL_EPSION on x86 NetBSD is wrong - shouldn't
it be the same as DBL_EPSILON on x86 NetBSD?
> If yes, I don't see the point of keeping <long double>
> different from <double>?
Well, you do get greater exponent range. But don't ask me,
it wasn't my decision.