*BSD News Article 9543


Return to BSD News archive

Received: by minnie.vk1xwt.ampr.org with NNTP
	id AA5946 ; Sat, 02 Jan 93 01:03:13 EST
Path: sserve!manuel.anu.edu.au!munnari.oz.au!spool.mu.edu!olivea!uunet!pipex!bnr.co.uk!uknet!cf-cm!myrddin.isl.cf.ac.uk!paul
From: paul@isl.cf.ac.uk (Paul Richards)
Newsgroups: comp.unix.bsd
Subject: Bug in mathlib (i.e. -lfpu)
Message-ID: <1993Jan4.213529.23355@cm.cf.ac.uk>
Date: 4 Jan 93 21:35:28 GMT
Sender: news@cm.cf.ac.uk (Network News System)
Organization: Intelligent Systems Lab, ELSYM, Universiity of Wales, College of 
              Cardiff.
Lines: 31

I was getting totally different results from a program when compiled
with the mathlib routines so I thought I'd track down the problem.

Anyway, pow seems to mess up the results of expressions when the
numerator of the expression is a function and pow is the denominator.
I'll try and track down the cause tomorrow (It's getting late here).

Below is a test program which shows the problem. Compile it with the
stock -lm and with -lfpu and note the difference.

Anyone who has used mathlib (Interviews people take note) needs to
check that their code doesn't do this.

----------------

#include <math.h>

float myproc()
{
return 1.0;
}

void main(void)
{
	int i;

      for (i=0; i <5; i++)
         printf("test %f\n",myproc()/(float)pow(2.0,1.0));
}

----------------