bug in 4.?bsd libnm version of sqrt (with fix)

Arthur David Olson ado at elsie.UUCP
Fri Jan 3 11:29:58 AEST 1986


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 at seismo.ARPA
	DEC, VAX and Elsie are Digital Equipment and Borden trademarks



More information about the Comp.bugs.4bsd.ucb-fixes mailing list