Article View: net.micro.mac
Article #7714Aztec C problem with pow() and exp(), and a fix
From: Rick Zaccone
Date: Sun, 19 Oct 1986 15:12
Date: Sun, 19 Oct 1986 15:12
64 lines
2307 bytes
2307 bytes
The following tests were done with version 1.06H.1 of the Manx Aztec C
compiler. The compilations were done
cc test.c
ln test.o -lm -lc
Here are the problems.
-----------------------------------------------------------------------
The function exp() does not work properly. Condiser the following
example:
#include <math.h>
#include <stdio.h>
main()
{
double x,z;
printf("Enter x: ");
scanf("%E", &x);
z = exp(x);
printf("exp(x) is %f:n", z);
}
Here are two sample runs with this program:
Enter x: 1
exp(x) is 2.330483 [Correct answer is 2.718281828]
Enter x: 10
exp(x) is 18988.393529 [Correct answer is 22026.465]
Note that is problem also manifests itself in pow(). Consider the
following program:
#include <math.h>
#include <stdio.h>
main()
{
double x,y,z;
printf("Enter x: ");
scanf("%E", &x);
printf("Enter y: ");
scanf("%E", &y);
z = pow(x, y);
printf("z is %f:n", z);
}
Enter x: 1.25
Enter y: 15
z is 30.158702 [Correct answer is 28.4217]
-----------------------------------------------------------------------
Manx claims that pow() and exp() "were not created properly".
To correct the problem extract the sources for exp() and pow() from
math.arc using arcv. Recompile them, and install them into m.lib
using libutil. I'm not sure if there is a problem in any of the other
math libraries. The above examples will work correctly after
recompiling pow() and exp().
--
Rick Zaccone Pennsylvania State University
CSNET: zaccone@penn-state BITNET: zaccone@psuvax1
UUCP: {akgua,allegra,burdvax,ihnp4}!psuvax1!zaccone
Technical Details
Message-ID:
<2310@psuvax1.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!watmath!clyde!caip!elbereth!rutgers!sri-spam!sri-unix!hplabs!sdcrdcf!burdvax!psuvax1!zacconeShow Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!caip!elbereth!rutgers!sri-spam!sri-unix!hplabs!sdcrdcf!burdvax!psuvax1!zaccone From: zaccone@psuvax1.UUCP (Rick Zaccone) Newsgroups: net.micro.mac Subject: Aztec C problem with pow() and exp(), and a fix Message-ID: <2310@psuvax1.UUCP> Date: Sun, 19-Oct-86 11:12:03 EDT Article-I.D.: psuvax1.2310 Posted: Sun Oct 19 11:12:03 1986 Date-Received: Tue, 21-Oct-86 22:32:42 EDT Distribution: net Organization: Pennsylvania State Univ. Lines: 64