[net.bugs.4bsd] bug in 4.?bsd libnm version of sqrt

ado@elsie.UUCP (Arthur David Olson) (01/03/86)

Index:		libnm/sqrt.s Fix

Description:
	The 4.?bsd "libnm" version of "sqrt" handles negative arguments
	differently than the way documented in the exp(3m) manual page.

Repeat-By:
	Feeding these lines to your favorite shell:
		cat > try.c << EOF
		main()
		{
			extern double	sqrt();
			extern int	errno;
			double		d;

			d = sqrt(-4.);
			printf("%d\n", errno);
			printf("%g\n", d);

		}
		EOF
		cc try.c -lnm
		a.out
	and noting the output:
		98
		-2
	which differs from the documented:
		33
		0

Fix:
	As usual, the trade secret status of the code involved precludes a
	clearer posting.  The change comes near the end of "libnm/sqrt.s":
		negarg:
		# Next few lines added by ado, January 1986
			.set	EDOM,33
			movl	$EDOM,_errno
			clrd	r0
			ret
		# Last few lines added by ado, January 1986
	Note also that the lines that originally followed the "negarg:" label
	may be removed.
--
Bugs is a Warner Brothers trademark.
--
	UUCP: ..decvax!seismo!elsie!ado    ARPA: elsie!ado@seismo.ARPA
	DEC, VAX and Elsie are Digital Equipment and Borden trademarks