Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 31 Oct 2002 20:28:33 +1100 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        "M. Warner Losh" <imp@bsdimp.com>
Cc:        tlambert2@mindspring.com, <rittle@labs.mot.com>, <rittle@latour.rsch.comm.mot.com>, <current@FreeBSD.ORG>, <dschultz@uclink.Berkeley.EDU>
Subject:   Re: Lack of real long double support
Message-ID:  <20021031202343.W8632-100000@gamplex.bde.org>
In-Reply-To: <20021030.170154.35505346.imp@bsdimp.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 30 Oct 2002, M. Warner Losh wrote:

> The one issue that I've seen is
>
>     long double a = 1.0L;
>     long double b = 1.0L + LDBL_EPSION
>     if (a == b) abort();
>
> which is what I'm trying to fix. (note, "1.0L" must be spelled
> "oneld()" and long double oneld() { return (1.0L);}) to avoid the
> optimizer getting it right.

Example of how fixing this breaks a similar assertion for DBL_ESPILON:

%%%
$ cat z.c
#include <float.h>
#include <floatingpoint.h>

long double oneld = 1.0L;
double oned = 1.0;

int
main()
{
	test(2);
	test(3);
}

int
test(int prec)
{
	long double la, lb;
	double a, b;

	fpsetprec(prec);
	la = oneld;
	lb = oneld + LDBL_EPSILON;
	if (la == lb)
		printf("LDBL_EPSILON failed test 1 with prec %d\n", prec);
	la = oneld;
	lb = oneld + LDBL_EPSILON / 2;
	if (la != lb)
		printf("LDBL_EPSILON failed test 2 with prec %d\n", prec);

	a = oned;
	b = oned + DBL_EPSILON;
	if (a == b)
		printf("DBL_EPSILON failed test 1 with prec %d\n", prec);
	a = oned;
	b = oned + DBL_EPSILON / 2;
	if (a != b)
		printf("DBL_EPSILON failed test 2 with prec %d\n", prec);
}
$ cc -o z z.c
$ ./z
LDBL_EPSILON failed test 1 with prec 2
$ cc -O -o z z.c.
$ ./z
LDBL_EPSILON failed test 1 with prec 2
DBL_EPSILON failed test 2 with prec 3
%%%

The full brokenness only shows up with -O.

Bruce


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021031202343.W8632-100000>