www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/08/15/15:34:40

Message-ID: <321373D7.70C4@pobox.oleane.com>
Date: Thu, 15 Aug 1996 21:00:39 +0200
From: Francois Charton <deef AT pobox DOT oleane DOT com>
Organization: CCMSA
MIME-Version: 1.0
To: djgpp AT delorie DOT com
CC: Thomas Demmer <demmer AT LSTM DOT Ruhr-UNI-Bochum DOT De>
Subject: new libm.a questions

Hi,

When using the math library libm.a from djgpp v2.0, I had floating point 
exceptions, when using functions like pow(). After asking the list, it 
was pointed to me that libm.a (actually exp() and scalb()) had a bug 
which caused this and that there was a patched library 
in ftp.lstm.ruhr-uni-bochum.de/pub/djgpp.

I have tried it today : works great, no exceptions. So, thanks everyone.


However, I have more and more doubts on the utility of libm.a.

Basic math functions, like pow(), are present both in libc.a 
(automatically linked to any djgpp program), and in libm.a. I did some 
timing experiments on both versions :
for pow() libm.a function is 3 times slower than libc.a function
if I use the "simpler" float version of pow, powf(), which is only in 
libm.a, I get a 15% increase in speed, which makes my function only 2.5 
times slower than the double libc version...

I then tried the same on cos(), which showed that libm and libc function 
performed identically (and that cosf() is not faster than cos()).

Finally, the only functions specific to libm.a are gammma() and bessel 
functions (not much used...).

For the rest, it seems that libm.a was a GNU product which aimed at 
calculating math functions with only multiplies, adds and the like, it 
probably does great on FPU emulator programs or machines with very slow 
floating point unit, but not on my 486 (and probably not on a Pentium 
either). And there is probably no point at using them in PC machines 
environments, such as those djgpp runs on.

On my machine, replacing libc.a functions by those of libm.a seems to be 
a bad choice (not mentionning the bug in libm...). But I fear this is 
just what "average users" like me would naturally do (link -lm in 
everytime they call math functions).

So, if my timings proved true on other machines, could it be possible :
1- that the FAQ warn potential misusers about this 
2- that the libm.a distribution is updated, so that either -lm slow 
functions are deleted or replaced by their libc.a equivalent whenever 
needed.

Francois

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019