Article View: net.bugs
Article #31Bug in BC Math library - (nf)
From: utzoodecvaxpur-eemalcolm
Date: Mon, 28 Jun 1982 22:49
Date: Mon, 28 Jun 1982 22:49
47 lines
1792 bytes
1792 bytes
#N:pur-ee:3200001:000:1374
pur-ee!malcolm Jun 28 22:46:00 1982
There seems to be a bug in the arctangent function supplied with bc.
I have checked several systems and can't pin down which systems have
this problem. So far I have found both V7 and 4BSD systems with this
problem.
The problem is that there is an if test at the start of the arctangent
code that checks for an arguement of 1. It then always returns a value
of 45 degrees. The offending code segement in /usr/lib/lib.b is shown
below:
define a(x){
auto a, b, c, d, e, f, g, s, t
if(x==0) return(0)
**** if(x==1)
**** if(scale<52)
**** return(.7853981633974483096156608458198757210492923498437764/1)
t = scale
f=1
while(x > .5){
scale = scale + 1
......and so on
There are two solutions to the problem. I am not sure which is better (or
even why the supplied code fails.) You can either remove the three lines
(which is how V6 supplied the code.) Or you can add '{}'s and do it right.
if(x==1){
if(scale<52){
return(.7853981633974483096156608458198757210492923498437764/1)
}
}
As long as I have your attention....Has anybody written a better program
to use as a desk calculator? Right now I don't have the time to reinvent
the wheel.
Thanks.
Malcolm Slaney
Purdue EE Dept.
decvax!pur-ee!malcolm
ihnss!pur-ee!malcolm
ucbvax!pur-ee!malcolm
harpo!pur-ee!malcolm
gsp86!intelqa!malcolm
Technical Details
Message-ID:
<bnews.pur-ee.376>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
From: utzoo!decvax!pur-ee!malcolm Newsgroups: net.bugs Title: Bug in BC Math library - (nf) Article-I.D.: pur-ee.376 Posted: Mon Jun 28 22:49:02 1982 Received: Tue Jun 29 04:43:32 1982 Subject: Bug in BC Math library - (nf) Date: Mon, 28 Jun 1982 22:49:02 +0000 Message-ID: <bnews.pur-ee.376>