xref: /csrg-svn/usr.bin/m4/TEST/sqroot.m4 (revision 47964)
138816Sbostic#
238816Sbostic# Copyright (c) 1989 The Regents of the University of California.
338816Sbostic# All rights reserved.
438816Sbostic#
538816Sbostic# This code is derived from software contributed to Berkeley by
638816Sbostic# Ozan Yigit.
738816Sbostic#
8*47964Sbostic# %sccs.include.redist.sh%
938816Sbostic#
10*47964Sbostic#	@(#)sqroot.m4	5.2 (Berkeley) 04/12/91
1138816Sbostic#
1238816Sbostic
1338816Sbosticdefine(square_root,
1438816Sbostic	`ifelse(eval($1<0),1,negative-square-root,
1538816Sbostic			     `square_root_aux($1, 1, eval(($1+1)/2))')')
1638816Sbosticdefine(square_root_aux,
1738816Sbostic	`ifelse($3, $2, $3,
1838816Sbostic		$3, eval($1/$2), $3,
1938816Sbostic		`square_root_aux($1, $3, eval(($3+($1/$3))/2))')')
20