*BSD News Article 20910


Return to BSD News archive

Xref: sserve comp.os.386bsd.apps:438 comp.os.386bsd.bugs:1393
Newsgroups: comp.os.386bsd.apps,comp.os.386bsd.bugs
Path: sserve!newshost.anu.edu.au!munnari.oz.au!spool.mu.edu!cass.ma02.bull.com!petra!news.bbn.com!olivea!charnel!yeshua.marcam.com!news.kei.com!sol.ctr.columbia.edu!howland.reston.ans.net!xlink.net!fauern!imp.ch!chsun!bernina!torda
From: torda@igc.ethz.ch (Andrew Torda)
Subject: Re: Bugs in FP emulator (was Re: Perl-4.036?)
Message-ID: <CDC4vs.22A@bernina.ethz.ch>
Sender: news@bernina.ethz.ch (USENET News System)
Nntp-Posting-Host: hermitage
Organization: Computational Chemistry, ETH, Zuerich
References: <26fptu$1q1@terminator.rs.itd.umich.edu> <CD9Dy6.B51@hippo.ru.ac.za> <2724fl$8fd@pdq.coe.montana.edu> <2728n2$bsn@mudos.pc.cc.cmu.edu>
Date: Tue, 14 Sep 1993 08:28:39 GMT
Lines: 30

mju@mudos.pc.cc.cmu.edu (Marc Unangst) wrote

>I believe the problem with the 'exp' tests under Perl is related
>to problems in the floating-point emulator.  On a system without
>hardware floating-point (486SLC/25), the following program prints
>"sqrt(2) = 2.000000".  On a system with hardware floating-point
>(486DX/33), it prints "sqrt(2) = 1.414214".  Both systems are running
>NetBSD 0.9 with the distributed versions of gcc 2.4.5 and npx.

Yes, this bug was mentioned in another thread recently.
An ugly work around, however, is to recompile sqrt() in the library,
libm.a without optimising.
   cp /usr/src/lib/libm/ieee/*.c /somewhere
   cp /usr/src/lib/libm/common_source/mathimpl.h /somewhere

   cd /somewhere
   gcc -Dnational -c support.c
the -Dnational tells it about byte ordering and is essential.

Now, try linking your test program against this support.o
It should work. To convince yourself, recompile support.o with -O. It
should break.

For the moment, I replaced the archive member in /usr/lib/libm.a,
although I can see that this does nothing to fix the real bug.
As mentioned in the quoted article, this is all on NetBSD 0.9 without
a real maths chip.
-Andrew
-- 
Andrew Torda, Computational Chemistry, ETH, Zurich, torda@igc.ethz.ch