From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111c93,fd21959b44c0a9b0 X-Google-Attributes: gid111c93,public X-Google-Thread: 10ba33,fd21959b44c0a9b0 X-Google-Attributes: gid10ba33,public From: michal@gortel.phys.ualberta.ca (Michal Jaegermann) Subject: Re: small doubles, g++, glibc, and linux/alpha problems Date: 1998/03/09 Message-ID: <6dvqal$9t2$1@pulp.ucs.ualberta.ca>#1/1 X-Deja-AN: 332125617 References: <3503303E.3E5B5838@ix.netcom.com> Followup-To: gnu.g++.help,comp.os.linux.alpha Reply-To: michal@gortel.phys.ualberta.ca X-Complaints-To: usenet@pulp.ucs.ualberta.ca X-Trace: pulp.ucs.ualberta.ca 889416853 10146 (None) 129.128.7.128 Organization: Disorganized Bits Newsgroups: gnu.g++.help,comp.os.linux.alpha C R Johnson (iamcliff@ix.netcom.com) wrote: : g++ 2.7 and egcs 1.0.1 running on a linux-alpha-glibc : system : is not taking kindly to small double values - those funky : near zero values that you know should be zero, but have : stupid values : like 2.38723e-314. If you are using denormalized values add -mieee flag to a compiler or you will get an exception. Saying that Richard Henderson fixed some kernel bugs in handling denormalized numbers in a kernel. You will find a "backport" to 2.0.3x series attached below: Michal --- linux-2.0.33/arch/alpha/math-emu/ieee-math.c~ Fri Apr 12 00:49:30 1996 +++ linux-2.0.33/arch/alpha/math-emu/ieee-math.c Thu Feb 12 17:39:04 1998 @@ -137,9 +137,8 @@ static inline void mul64 (const unsigned long a, const unsigned long b, unsigned long c[2]) { - asm ("mulq %2,%3,%0\n\t" - "umulh %2,%3,%1" - : "r="(c[0]), "r="(c[1]) : "r"(a), "r"(b)); + c[0] = a * b; + asm ("umulh %1,%2,%0" : "=r"(c[1]) : "r"(a), "r"(b)); } @@ -276,7 +275,7 @@ { unsigned long res, sticky; - if (!a->f[0] && !a->f[1]) { + if (!a->e && !a->f[0] && !a->f[1]) { *b = (unsigned long) a->s << 63; /* return +/-0 */ return 0; } @@ -356,7 +355,7 @@ { unsigned long res, sticky; - if (!a->f[0] && !a->f[1]) { + if (!a->e && !a->f[0] && !a->f[1]) { *b = (unsigned long) a->s << 63; /* return +/-0 */ return 0; } @@ -384,7 +383,7 @@ a->e = -0x3ff; } } - if (a->e > 0x3ff) { + if (a->e >= 0x3ff) { res = FPCR_OVF | FPCR_INE; if (f & IEEE_TRAP_ENABLE_OVF) { a->e -= 0x600; /* scale down result by 2^alpha */ @@ -1143,12 +1142,9 @@ return 0; } op_c.s = op_a.s ^ op_b.s; - op_c.e = op_a.e + op_b.e; + op_c.e = op_a.e + op_b.e - 55; mul64(op_a.f[0], op_b.f[0], op_c.f); - normalize(&op_c); - op_c.e -= 55; /* drop the 55 original bits. */ - return round_s_ieee(f, &op_c, c); } @@ -1200,11 +1196,8 @@ return 0; } op_c.s = op_a.s ^ op_b.s; - op_c.e = op_a.e + op_b.e; + op_c.e = op_a.e + op_b.e - 55; mul64(op_a.f[0], op_b.f[0], op_c.f); - - normalize(&op_c); - op_c.e -= 55; /* drop the 55 original bits. */ return round_t_ieee(f, &op_c, c); }