From: michal@gortel.phys.ualberta.ca (Michal Jaegermann)
Subject: Re: small doubles, g++, glibc, and linux/alpha problems
Date: 1998/03/09 [thread overview]
Message-ID: <6dvqal$9t2$1@pulp.ucs.ualberta.ca> (raw)
In-Reply-To: 3503303E.3E5B5838@ix.netcom.com
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);
}
prev parent reply other threads:[~1998-03-09 5:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-03-08 5:00 small doubles, g++, glibc, and linux/alpha problems C R Johnson
1998-03-08 5:00 ` H.W. Stockman
1998-03-09 5:00 ` Michal Jaegermann [this message]
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox