[comp.bugs.4bsd] bc BUG!!!!!

thaeler@hc.DSPO.GOV (Bret K. Thaeler) (11/24/87)

try this....

	% bc -l
	a(0.0) --> 0		GOOD
	a(1.0) --> .785398...	GOOD

	a(2.0) --> .785398...	NO NO NO BAD BAD BAD
	a(0.5) --> .785398...	BAD
	a(1.5) --> .785398...	BAD
	a(3.0) --> .785398...	BAD


How could this have taken so long to find??? Am I really
the first????

			-Bret Thaeler
			(thaeler@hc.dspo.gov)

thaeler@hc.DSPO.GOV (Bret K. Thaeler) (11/24/87)

This is a reposting.....


try this on your favorit 4.3BSD system.....

	% bc -l
	a(0.0) --> 0		GOOD
	a(1.0) --> .785398...	GOOD

	a(2.0) --> .785398...	NO NO NO BAD BAD BAD
	a(0.5) --> .785398...	BAD
	a(1.5) --> .785398...	BAD
	a(3.0) --> .785398...	BAD


How could this have taken so long to find??? Am I really
the first????

			-Bret Thaeler
			(thaeler@hc.dspo.gov)

thomson@uthub.UUCP (11/24/87)

The arctan bug in the bc(1) library is an old bug.
Edit /usr/lib/lib.b and make sure that the following lines
in routine a() are fully bracketed as they are below:


	if(x==1) {
		if(scale<52) {
			return(.785... etc)
		}
	}
-- 
		    Brian Thomson,	    CSRI Univ. of Toronto
		    utcsri!uthub!thomson, thomson@hub.toronto.edu

trt@rti.UUCP (11/25/87)

There are some ancient problems in "bc -l" that
have relatively ancient fixes.
The following applies mainly to BSD,
recent AT&T versions are probably fine as is.

Diff diff listing for /usr/lib/lib.b:

*** lib.b.orig	Sat Oct 18 23:32:50 1986
--- lib.b	Sat Feb  7 15:51:30 1987
***************
*** 4,6 ****
  define e(x){
! 	auto a, b, c, d, e, g, w, y
  
--- 4,8 ----
  define e(x){
! 	auto a, b, c, d, e, g, w, y, t
! 	/* ukc.4076, ukc!dcw, D.C. Wood, Univ. of Kent, */
! 	/* Feb 3 1984 declare 't' as auto */
  
***************
*** 127,131 ****
  	if(x==0) return(0)
! 	if(x==1)
! 		if(scale<52)
  return(.7853981633974483096156608458198757210492923498437764/1)
  	t = scale
--- 129,137 ----
  	if(x==0) return(0)
! 	/* umn-cs.410, umn-cs!herndon, Robert Herndon, */
! 	/* Jan 31 1984, avoid if bug. */
! 	if(x==1) {
! 		if(scale<52) {
  return(.7853981633974483096156608458198757210492923498437764/1)
+ 		}
+ 	}
  	t = scale