Testing math library (libm) for new processor?

Peter S. Housel housel at en.ecn.purdue.edu
Sat Jul 8 01:28:26 AEST 1989


In article <1989Jun29.155325.28676 at utzoo.uucp>, henry at utzoo (Henry Spencer) writes:
>In article <2035 at dataio.Data-IO.COM> bright at dataio.Data-IO.COM (Walter Bright) writes:
>><I am writing a math library (equivalent to libm.a on most UNiX systems) for
>><a new processor.  (Functions like sin, cos, log, etc.) ...
>>The best one is:
>>	"Software Manual For The Elementary Functions"
>Note, however, that Cody&Waite is old.  If your machine uses IEEE floating
>point (fairly likely these days), you should not be writing your own math
>library -- you should be picking up the freely-redistributable 4.3BSD math
>library, which had input from people like Kahan and is almost certainly
>better than anything you can do yourself in any reasonable length of time.
>Kahan commented, as I recall, that there is nothing wrong with Cody&Waite,
>but their stuff is aimed at old, ill-behaved floating-point hardware, and
>on IEEE hardware you can do better.
>
>The 4.3 math library appeared in comp.sources.unix late last year.

I missed the original discussion, and this may be a stale topic by now,
but...

I have recently finished adding floating point to the Minix-PC C
compiler and C library. The bits are arranged the same way as most
IEEE implementations, but there is only one rounding mode (round-to-nearest)
and there are no NaN's or infinities.

Everything freely redistributable from 4.3Tahoe that will work has
gone into the pot. The new _doprnt() (renamed vfprintf()) worked
without much trouble. The VAX atof.s was translated almost verbatim
into C and 8086 assembly, and reworked into strtod().

However, after looking at the libm sources, I threw up my hands and
started reading up on numerical computation. No offense to the authors
intended, but this code is ugly! I can't make head nor tail of much of
it.

Sure, most of these programs are accurate to the last bit of the
significand. But the price is code that freely twiddles with the bits in
an opaque manner. Anyone who can figure out drem() or sqrt() in either
the C or assembly implementations is worthy of respect.

I have been stealing coefficient vectors from this code when writing
my own. The code is clean, behaves according to K&R2, and most of it
is numerically safe, but it isn't nearly as clever and accurate as the
4.3 libm.

Does anybody know if either Hart and Cheney, or Cody and Waite, are still
in print? I can't find either one in the local libraries. [The kind with
books in them, not object files.]

Also, was the proprietary code exorcised before the 4.3-Tahoe release was
made?  Can I assume that everything from the Tahoe tape with a "Freely
Redistributable" copyright, really is? Also, was it AT&T code, or CCI's?

(Expect whatever is done by then to be posted to comp.os.minix at the end
of this month.)

-Peter S. Housel-	housel at ecn.purdue.edu		...!pur-ee!housel



More information about the Comp.lang.c mailing list