sqroot.m4 revision 250226
160107Sobrien#	$OpenBSD: sqroot.m4,v 1.3 2003/06/03 02:56:11 millert Exp $
243334Syokota#	$NetBSD: sqroot.m4,v 1.4 1995/09/28 05:38:01 tls Exp $
343334Syokota#
443334Syokota# Copyright (c) 1989, 1993
543334Syokota#	The Regents of the University of California.  All rights reserved.
643334Syokota#
743334Syokota# This code is derived from software contributed to Berkeley by
843334Syokota# Ozan Yigit.
943334Syokota#
10270114Sse# Redistribution and use in source and binary forms, with or without
11270229Sse# modification, are permitted provided that the following conditions
1243334Syokota# are met:
1343334Syokota# 1. Redistributions of source code must retain the above copyright
1443334Syokota#    notice, this list of conditions and the following disclaimer.
1543334Syokota# 2. Redistributions in binary form must reproduce the above copyright
1643334Syokota#    notice, this list of conditions and the following disclaimer in the
1743334Syokota#    documentation and/or other materials provided with the distribution.
1843334Syokota# 3. Neither the name of the University nor the names of its contributors
19270114Sse#    may be used to endorse or promote products derived from this software
2043334Syokota#    without specific prior written permission.
2143334Syokota#
2243334Syokota# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2343334Syokota# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24270114Sse# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2543334Syokota# ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2643334Syokota# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2743334Syokota# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2843334Syokota# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2943334Syokota# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3043334Syokota# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3143334Syokota# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32270114Sse# SUCH DAMAGE.
33270229Sse#
3443334Syokota# $FreeBSD: head/usr.bin/m4/TEST/sqroot.m4 250226 2013-05-03 23:29:38Z jkim $
3543334Syokota#
3643334Syokota#	@(#)sqroot.m4	8.1 (Berkeley) 6/6/93
3743334Syokota#
3843334Syokota
3943334Syokotadefine(square_root, 
4043334Syokota	`ifelse(eval($1<0),1,negative-square-root,
4143334Syokota			     `square_root_aux($1, 1, eval(($1+1)/2))')')
4243334Syokotadefine(square_root_aux,
4343334Syokota	`ifelse($3, $2, $3,
4443334Syokota		$3, eval($1/$2), $3,
45270114Sse		`square_root_aux($1, $3, eval(($3+($1/$3))/2))')')
46270114Sse